/** * 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); } } } }
/** * Function creates the header of the presenter * @return string */ public function getHeader() { return sprintf("Tests: %d, Assertions: %d, Failures: %d, Errors: %d, Ignored: %d, Incomplete: %d, Time: %f seconds, Memory: %s \n", $this->result->count(), $this->result->getAssertionsCount(), $this->result->getFailureCount(), $this->result->getErrorCount(), $this->result->getSkippedCount(), $this->result->getNotImplementedCount(), CIUnit_Util_Timer::secondsToTimeString($this->result->getExecutionTime()), CIUnit_Util_Memory::getUsedMemory()); }