Пример #1
0
 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());
 }
Пример #2
0
 public ERXTestResult doRun(Test suite) {
   testResult.addListener(this);
   long startTime = System.currentTimeMillis();
   suite.run(testResult);
   long endTime = System.currentTimeMillis();
   runTime = endTime - startTime;
   return testResult;
 }
 /** Overrides parent method to pass in device to included test */
 @Override
 public void runTest(Test test, TestResult result) {
   if (test instanceof IDeviceTest) {
     IDeviceTest deviceTest = (IDeviceTest) test;
     deviceTest.setDevice(mDevice);
   }
   test.run(result);
 }
Пример #4
0
 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);
 }
Пример #5
0
  public TestResult doRun(Test suite, boolean wait) {
    TestResult result = createTestResult();
    result.addListener(fPrinter);
    long startTime = System.currentTimeMillis();
    suite.run(result);
    long endTime = System.currentTimeMillis();
    long runTime = endTime - startTime;
    fPrinter.print(result, runTime);

    pause(wait);
    return result;
  }
Пример #6
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());
 }
Пример #7
0
    @Override
    public TestResult call() throws Exception {
      Lock lock;
      if (isThreadHostile(test)) {
        // Thread hostile tests need to run alone and therefore require the write lock.
        lock = globalStateLock.writeLock();
      } else {
        // Regular tests can run concurrently
        lock = globalStateLock.readLock();
      }

      // Run the test.
      lock.lock();
      try {
        test.run(result);
        return result;
      } finally {
        lock.unlock();
      }
    }
Пример #8
0
  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);
    }
  }
Пример #9
0
 /** Runs a test and collects its result in a TestResult instance. */
 public void run(TestResult result) {
   test.run(result);
 }
Пример #10
0
 public void run() {
   status = RUNNING;
   timestamp = new Date();
   test.run(result);
 }
Пример #11
0
 @Override
 public void run(TestResult result) {
   mDelegate.run(result);
   mDelegate = null;
 }