public void init() { Enumeration testsEnum = suite.tests(); while (testsEnum.hasMoreElements()) { Test test = (Test) testsEnum.nextElement(); TestInfo testInfo = new TestInfo(test, this); addTestInfo(testInfo); } }
/** @param suite the suite to add to the model. */ private void addSuite(Type type, TestSuite suite) { for (Enumeration<Test> e = suite.tests(); e.hasMoreElements(); ) { Test test = e.nextElement(); if (test instanceof TestSuite) { addSuite(type, (TestSuite) test); } else { inventory.put(test.toString(), test); testCasesType.put(test.toString(), type); } } }
public static List<Test> collectCases(TestSuite suite) { List<Test> answer = new ArrayList<Test>(); for (Test test : toList(suite.tests())) { if (test instanceof TestSuite) { answer.addAll(collectCases((TestSuite) test)); } else { answer.add(test); } } return answer; }
public void visit(TestSuite testSuite) { handler.startingTestSuite(testSuite); Enumeration tests = testSuite.tests(); while (tests.hasMoreElements()) { Test test = (Test) tests.nextElement(); if (test instanceof TestSuite) { visit((TestSuite) test); } else { handler.handleTestCase(test); } } handler.completedTestSuite(testSuite); }
/** * Creates a new test suite that runs tests in bytecode declaration order. * * @param testClass the JUnit-3-style test class * @param name the name of the suite * @since 3.9 */ public OrderedTestSuite(Class testClass, String name) { super(name); TestSuite vmOrderSuite = new TestSuite(testClass); ArrayList tests = Collections.list(vmOrderSuite.tests()); class SortingException extends RuntimeException { private static final long serialVersionUID = 1L; public SortingException(String message) { super(message); } } try { final List orderedMethodNames = getBytecodeOrderedTestNames(testClass); Collections.sort( tests, new Comparator() { @Override public int compare(Object o1, Object o2) { if (o1 instanceof TestCase && o2 instanceof TestCase) { TestCase t1 = (TestCase) o1; TestCase t2 = (TestCase) o2; int i1 = orderedMethodNames.indexOf(t1.getName()); int i2 = orderedMethodNames.indexOf(t2.getName()); if (i1 != -1 && i2 != -1) return i1 - i2; } throw new SortingException( "suite failed to detect test order: " + o1 + ", " + o2); //$NON-NLS-1$ //$NON-NLS-2$ } }); } catch (SortingException e) { addTest(error(testClass, "suite failed to detect test order", e)); // $NON-NLS-1$ } catch (IOException e) { addTest(error(testClass, "suite failed to detect test order", e)); // $NON-NLS-1$ } for (Iterator iter = tests.iterator(); iter.hasNext(); ) { Test test = (Test) iter.next(); addTest(test); } }
static TestSuite getSuite(Class testClass) throws Exception { TestSuite suite = new TestSuite(); for (int i = 0; i < ALL.length; i += 2) { String originalClsName = ALL[i]; String evolvedClsName = ALL[i + 1]; if (evolvedClsName == null) { evolvedClsName = originalClsName; } TestSuite baseSuite = new TestSuite(testClass); Enumeration e = baseSuite.tests(); while (e.hasMoreElements()) { EvolveTestBase test = (EvolveTestBase) e.nextElement(); test.init(originalClsName, evolvedClsName); suite.addTest(test); } } return suite; }
/** {@inheritDoc} */ @Override public Enumeration<Test> tests() { return isDisabled ? copy.tests() : super.tests(); }
protected Enumeration getSuites(TestSuite all) { return all.tests(); }