









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Developing, Testing, Debugging
Some slides adapted from FSE’98 Tutorial by Michal Young and Mauro Pezze’
Decision Procedure
Property
Program
Pass/Fail
Perfect verification
Optimistic inaccuracy (testing)
Pessimistic inaccuracy (analysis, proofs)
“Easier” properties
synchronized(S) { ... ... }
Static checking for match is necessarily inaccurate ... ... so Java prescribes a more restrictive, but statically checkable construct.
if ( .... ) { ... lock(S); } ... if ( ... ) { ... unlock(S); }
inputs outputs subcomponent being tested
Is it correct?
oracle
public class LogRecordTest extends TestCase { protected String event1 = “test”; public void testEquals1() { LogRecord tmp1 = new LogRecord(event1+”1”);LogRecord tmp2 = new LogRecord(event1+”2”); assertTrue(tmp1.equals(tmp1)); // should pass }assertTrue(tmp1.equals(tmp2)); // should fail public void runTest () { testEquals1(); } public static void main (String [] args) {TestResult result = (new LogRecordTest("testLogRecord")).run(); if (!result.wasSuccessful()) { System.out.println(“Doh!”); } } }
Create objects Perform test/ check result
public class LogRecordTest extends TestCase { protected String event1;LogRecord tmp1, tmp2; public void setUp() {event1 = “test”; tmp1 = new LogRecord(event1+”1”); }tmp2 = new LogRecord(event1+”2”); public void testEquals1() { assertTrue(tmp1.equals(tmp1)); // should pass }assertTrue(tmp1.equals(tmp2)); // should fail // other cases here will reuse tmp1, tmp2, event1, etc. … }
Create objects at outset
Perform test/ check result