public void testActiveRepeatedTest1() { Test test = new RepeatedTest(createActiveTestSuite(), 1); TestResult result = new TestResult(); test.run(result); assertEquals(100, result.runCount()); assertEquals(0, result.failureCount()); assertEquals(0, result.errorCount()); }
public void testNoArgTestCasePasses() { Test t = new TestSuite(NoArgTestCaseTest.class); TestResult result = new TestResult(); t.run(result); assertTrue(result.runCount() == 1); assertTrue(result.failureCount() == 0); assertTrue(result.errorCount() == 0); }
public void testExceptionRunningAndTearDown() { // This test documents the current behavior. With 1.4, we should // wrap the exception thrown while running with the exception thrown // while tearing down Test t = new TornDown() { public void tearDown() { throw new Error("tearDown"); } }; TestResult result = new TestResult(); t.run(result); TestFailure failure = (TestFailure) result.errors().nextElement(); assertEquals("tearDown", failure.thrownException().getMessage()); }
private void runNextTest(final TestResult testResult, int totalTests, Class testCaseClass) { myRunTests++; if (!checkAvaliableMemory(35, testResult)) { testResult.stop(); return; } if (testResult.errorCount() + testResult.failureCount() > MAX_FAILURE_TEST_COUNT) { addErrorMessage( testResult, "Too many errors. Tests stopped. Total " + myRunTests + " of " + totalTests + " tests run"); testResult.stop(); return; } if (myStartTime == 0) { boolean ourClassLoader = getClass().getClassLoader().getClass().getName().startsWith("com.intellij."); if (!ourClassLoader) { beforeFirstTest(); } } else { if (myInterruptedByOutOfTime) { addErrorMessage( testResult, "Current Test Interrupted: OUT OF TIME! Class = " + myLastTestClass + " Total " + myRunTests + " of " + totalTests + " tests run"); testResult.stop(); return; } } log("\nRunning " + testCaseClass.getName()); final Test test = getTest(testCaseClass); if (test == null) return; myLastTestClass = null; myLastTestClass = testCaseClass.getName(); myLastTestStartTime = System.currentTimeMillis(); myLastTestTestMethodCount = test.countTestCases(); try { test.run(testResult); } catch (Throwable t) { if (t instanceof OutOfMemoryError) { if ((ourMode & SAVE_MEMORY_SNAPSHOT) != 0) { try { mySavingMemorySnapshot = true; log("OutOfMemoryError detected. Saving memory snapshot started"); } finally { log("Saving memory snapshot finished"); mySavingMemorySnapshot = false; } } } testResult.addError(test, t); } }
@auto public void main() { test.run(); }