private static Description makeDescription(Test test) { if (test instanceof TestCase) { TestCase tc = (TestCase) test; return Description.createTestDescription(tc.getClass(), tc.getName(), getAnnotations(tc)); } else if (test instanceof TestSuite) { TestSuite ts = (TestSuite) test; String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName(); Description description = Description.createSuiteDescription(name); int n = ts.testCount(); for (int i = 0; i < n; i++) { Description made = makeDescription(ts.testAt(i)); description.addChild(made); } return description; } else if (test instanceof Describable) { Describable adapter = (Describable) test; return adapter.getDescription(); } else if (test instanceof TestDecorator) { TestDecorator decorator = (TestDecorator) test; return makeDescription(decorator.getTest()); } else { // This is the best we can do in this case return Description.createSuiteDescription(test.getClass()); } }
/* 109: */ /* 110: */ private static Description makeDescription(Test test) /* 111: */ { /* 112: 96 */ if ((test instanceof TestCase)) /* 113: */ { /* 114: 97 */ TestCase tc = (TestCase) test; /* 115: 98 */ return Description.createTestDescription(tc.getClass(), tc.getName()); /* 116: */ } /* 117: 99 */ if ((test instanceof TestSuite)) /* 118: */ { /* 119:100 */ TestSuite ts = (TestSuite) test; /* 120:101 */ String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName(); /* 121:102 */ Description description = Description.createSuiteDescription(name, new Annotation[0]); /* 122:103 */ int n = ts.testCount(); /* 123:104 */ for (int i = 0; i < n; i++) /* 124: */ { /* 125:105 */ Description made = makeDescription(ts.testAt(i)); /* 126:106 */ description.addChild(made); /* 127: */ } /* 128:108 */ return description; /* 129: */ } /* 130:109 */ if ((test instanceof Describable)) /* 131: */ { /* 132:110 */ Describable adapter = (Describable) test; /* 133:111 */ return adapter.getDescription(); /* 134: */ } /* 135:112 */ if ((test instanceof TestDecorator)) /* 136: */ { /* 137:113 */ TestDecorator decorator = (TestDecorator) test; /* 138:114 */ return makeDescription(decorator.getTest()); /* 139: */ } /* 140:117 */ return Description.createSuiteDescription(test.getClass()); /* 141: */ }
/** Tears down the fixture. Override to tear down the additional fixture state. */ protected void tearDown() throws Exception { if (m_suite.testCount() > 0) { teardownSQL(); if (m_performInitialization) { Initializer.shutdown(); } } }
/** Sets up the fixture. Override to set up additional fixture state. */ protected void setUp() throws Exception { if (m_suite.testCount() > 0) { if (m_performInitialization) { ResourceManager.getInstance().setServletContext(new DummyServletContext()); Initializer.startup(m_suite, m_scriptName, m_iniName); setupSQL(); } } }
/** * Copies non-distributed test suite into distributed one. * * @param suite Test suite to copy. */ public GridJunit3TestSuite(TestSuite suite) { super(suite.getName()); if (copy == null) { copy = new TestSuite(suite.getName()); } for (int i = 0; i < suite.testCount(); i++) { addTest(suite.testAt(i)); } }
/** * @param suite Test suite to wrap. * @param factory Proxy factory. */ GridJunit3TestSuiteProxy(TestSuite suite, GridJunit3ProxyFactory factory) { assert suite != null; assert factory != null; original = suite; setName(suite.getName()); this.factory = factory; for (int i = 0; i < suite.testCount(); i++) { addTest(suite.testAt(i)); } }
public static TestSuite suite() { TestSuite suite = new TestSuite(); Method[] methods = Monitor.class.getMethods(); sortMethods(methods); for (Method method : methods) { if (isAnyEnter(method) || isWaitFor(method)) { validateMethod(method); addTests(suite, method); } } assertEquals(548, suite.testCount()); return suite; }
/** * Usage: java -cp ... AllTests file.jar [--only-run-slow-tests] * * <p>--only-run-slow-tests parameter only run test in classes annotated with @SlowTest, else * these tests will be skipped. * * @param args the command line arguments */ public static void main(String[] args) throws Exception { if (args.length > 0 && args.length <= 2) { jarFile = args[0]; if (args.length > 1) { if (args[1].equalsIgnoreCase("--only-run-slow-tests")) { onlyRunSlowTests = true; } } System.out.println("Running all tests in '" + jarFile + "'"); TestSuite suite = (TestSuite) suite(); System.out.println("Found '" + suite.testCount() + "' test classes in jar file."); TestResult res = junit.textui.TestRunner.run(suite); System.exit(res.wasSuccessful() ? 0 : 1); } else { usage(); } }
public void filter(Filter filter) throws NoTestsRemainException { if (getTest() instanceof Filterable) { Filterable adapter = (Filterable) getTest(); adapter.filter(filter); } else if (getTest() instanceof TestSuite) { TestSuite suite = (TestSuite) getTest(); TestSuite filtered = new TestSuite(suite.getName()); int n = suite.testCount(); for (int i = 0; i < n; i++) { Test test = suite.testAt(i); if (filter.shouldRun(makeDescription(test))) { filtered.addTest(test); } } setTest(filtered); } }
/** * Handles test fail. * * @param result Test result. * @param origTest Original JUnit test. * @param e Exception thrown from grid. */ private void handleFail(TestResult result, GridJunit3SerializableTest origTest, Throwable e) { // Simulate that all tests were run. origTest.getTest().run(result); // For the tests suite we assume that all tests failed because // entire test suite execution failed and there is no way to get // broken tests. if (origTest.getTest() instanceof GridJunit3TestSuiteProxy) { TestSuite suite = (((TestSuite) origTest.getTest())); for (int j = 0; j < suite.testCount(); j++) { result.addError(suite.testAt(j), e); } } else if (origTest.getTest() instanceof GridJunit3TestCaseProxy) { result.addError(origTest.getTest(), e); } }
@Override public void run() { Collection<TestInventory> inventories = ServiceLocator.get().getAll(TestInventory.class); for (TestInventory i : inventories) { for (Type type : scope) { TestSuite suite = i.getTestSuite(type); if (suite.testCount() > 0) { addSuite(type, suite); } } } for (Test t : inventory.values()) { Map<String, Object> testWithProps = Maps.newHashMap(); testWithProps.put("name", t.toString()); testWithProps.put("selected", false); testWithProps.put("status", "Not Run Yet"); testWithProps.put("exception", ""); testWithProps.put("isHidden", ""); testWithProps.put("type", testCasesType.get(t.toString()).toString().toLowerCase()); testWithProps.put("isPerf", t instanceof PerfExecutorTest); testWithProps.put("perfInfo", ""); String url = ""; if (t instanceof ComponentTestCase) { url = ((ComponentTestCase) t).getAppUrl(); } if (t instanceof PerfExecutorTest) { // url = ((PerfExecutorTest) t).generateUrl(); List<String> urls = ((PerfExecutorTest) t).generateUrl(); if (urls.size() > 1) { for (String u : urls) { testWithProps.put("jsConsole", u); testsWithPropsMap.put(t.toString(), testWithProps); } return; } url = urls.get(0); } testWithProps.put("jsConsole", url); testsWithPropsMap.put(t.toString(), testWithProps); } }
/* 149: */ /* 150: */ public void filter(Filter filter) /* 151: */ throws NoTestsRemainException /* 152: */ { /* 153:128 */ if ((getTest() instanceof Filterable)) /* 154: */ { /* 155:129 */ Filterable adapter = (Filterable) getTest(); /* 156:130 */ adapter.filter(filter); /* 157: */ } /* 158:131 */ else if ((getTest() instanceof TestSuite)) /* 159: */ { /* 160:132 */ TestSuite suite = (TestSuite) getTest(); /* 161:133 */ TestSuite filtered = new TestSuite(suite.getName()); /* 162:134 */ int n = suite.testCount(); /* 163:135 */ for (int i = 0; i < n; i++) /* 164: */ { /* 165:136 */ Test test = suite.testAt(i); /* 166:137 */ if (filter.shouldRun(makeDescription(test))) { /* 167:138 */ filtered.addTest(test); /* 168: */ } /* 169: */ } /* 170:140 */ setTest(filtered); /* 171: */ } /* 172: */ }
/** {@inheritDoc} */ @Override public int testCount() { return isDisabled ? copy.testCount() : super.testCount(); }