1 package junit.tests; 2 3 import junit.framework.*; 4 5 8 public class TestImplementorTest extends TestCase { 9 public static class DoubleTestCase implements Test { 10 private TestCase fTestCase; 11 12 public DoubleTestCase(TestCase testCase) { 13 fTestCase= testCase; 14 } 15 16 public int countTestCases() { 17 return 2; 18 } 19 20 public void run(TestResult result) { 21 result.startTest(this); 22 Protectable p= new Protectable() { 23 public void protect() throws Throwable { 24 fTestCase.runBare(); 25 fTestCase.runBare(); 26 } 27 }; 28 result.runProtected(this, p); 29 result.endTest(this); 30 } 31 } 32 33 private DoubleTestCase fTest; 34 35 public TestImplementorTest(String name) { 36 super(name); 37 TestCase testCase= new TestCase("noop") { 38 public void runTest() { 39 } 40 }; 41 fTest= new DoubleTestCase(testCase); 42 } 43 44 public void testSuccessfulRun() { 45 TestResult result= new TestResult(); 46 fTest.run(result); 47 assertEquals(fTest.countTestCases(), result.runCount()); 48 assertEquals(0, result.errorCount()); 49 assertEquals(0, result.failureCount()); 50 } 51 } 52 | Popular Tags |