예제 #1
0
 /**
  * Runs a TestCase
  *
  * @param
  *            CIUnit_Framework_TestInterface$test
  * @since version 1.0.0
  */
 public function run(CIUnit_Framework_TestInterface $test)
 {
     // Reset the number of assertions in CIUnit_Framework_Assert
     // class
     CIUnit_Framework_Assert::resetAssertionCount();
     // Create local flags for error, skipped incomplete and failure = FALSE
     $error = FALSE;
     $failure = FALSE;
     $incomplete = FALSE;
     $skipped = FALSE;
     // Start php timer PHP_Timer::start()
     CIUnit_Util_Timer::start();
     // Call runBare or use invoker class
     try {
         $test->runTestSequence();
     } catch (CIUnit_Framework_Exception_AssertionFailed $e) {
         $failure = TRUE;
         if ($e instanceof CIUnit_Framework_Exception_SkippedTest) {
             $skipped = TRUE;
         } else {
             if ($e instanceof CIUnit_Framework_Exception_IncompleteTest) {
                 $incomplete = TRUE;
             }
         }
     } catch (Exception $e) {
         $error = TRUE;
     }
     // Stop PHP timer
     $executionTime = CIUnit_Util_Timer::stop();
     // Add the current Asset class assertion count to TestCase assertions
     // count
     $test->addAssertionCount(CIUnit_Framework_Assert::getAssertionCount());
     $this->totalNuberOfTestsToRun += $test->count();
     $this->assertionsCount += $test->getNumberOfAssertions();
     // Call $this->addError or $this->addFailure
     if ($error === TRUE) {
         $this->addError($test, $e, $executionTime);
     } else {
         if ($failure === TRUE) {
             $this->addFailure($test, $e, $executionTime);
         } else {
             if ($test->getNumberOfAssertions() == 0) {
                 $this->addFailure($test, new CIUnit_Framework_Exception_IncompleteTest('Test did not perform any assertions'), $executionTime);
             } else {
                 $this->addSuccess($test, $executionTime);
             }
         }
     }
 }