1 19 20 package org.netbeans.test.xml.schema.core.lib.sequential; 21 22 import java.util.Iterator ; 23 import junit.framework.Test; 24 import junit.framework.TestResult; 25 import junit.framework.TestSuite; 26 27 28 32 public class SequentialTestSuite extends TestSuite { 33 private TestSequence m_testSequence; 34 35 36 public SequentialTestSuite(String name, TestSequence testSequence) { 37 super(name); 38 m_testSequence = testSequence; 39 } 40 41 public int countTestCases() { 42 return 1; } 44 45 public void run(TestResult result) { 46 try { 47 recurseTests(m_testSequence, result); 48 } finally { 49 m_testSequence.finalCleanup(); 50 } 51 } 52 53 private void recurseTests(SequentialTest sequentialTest, TestResult result) { 54 55 sequentialTest.setupOnce(); 56 57 while (true) { 58 if (result.shouldStop()) { 59 break; 60 } 61 62 sequentialTest.setup(); 63 64 if (sequentialTest.isCompleted()) { 65 break; 66 } 67 68 if (sequentialTest.needsExecution()) { 69 String testName = sequentialTest.getTestName().trim(); 70 Test test = new SequentialTestCase(testName, sequentialTest); 71 runTest(test, result); 72 } 73 74 if (sequentialTest instanceof TestSequence) { 75 TestSequence sequence = (TestSequence) sequentialTest; 76 77 Iterator <SequentialTest> iterator = sequence.getIterator(); 78 if (iterator != null) { 79 while(iterator.hasNext()) { 80 SequentialTest st = iterator.next(); 81 recurseTests(st, result); 82 } 83 } 84 } 85 86 sequentialTest.cleanup(); 87 } 88 89 sequentialTest.cleanupOnce(); 90 } 91 } 92 | Popular Tags |