Exemple #1
0
 private function performAllUnitTests()
 {
     $this->_unitTestResult->setUnitTestName($this->_unitTestName);
     $testMethods = $this->getTestMethods();
     foreach ($testMethods as $method) {
         $milliTimespan = new MilliTimespan();
         $testCase = new TestCaseResult($milliTimespan);
         $this->_currentTestCase = $testCase;
         $testName = str_replace('_', ' ', $method);
         $testCase->setTestCaseName($testName);
         $this->_assertCount = 0;
         $testCase->startTestCase();
         $this->setUp();
         $this->{$method}();
         $this->tearDown();
         $testCase->stopTestCase();
         $testCase->setAssertCount($this->_assertCount);
         $this->_unitTestResult->addTestCaseResult($testCase);
     }
     $unitTestResult = $this->_unitTestResult;
     self::$_summary->addUnitTestResult($unitTestResult);
 }
Exemple #2
0
 public function test_correct_percentage_failed()
 {
     $unitTestResult = new UnitTestResult();
     $milliTimespanMock1 = new MilliTimespanMock();
     $testCaseResult1 = new TestCaseResult($milliTimespanMock1);
     $testCaseResult1->startTestCase();
     $testCaseResult1->stopTestCase();
     $testCaseResult1->setTestPassed();
     $unitTestResult->addTestCaseResult($testCaseResult1);
     $milliTimespanMock2 = new MilliTimespanMock();
     $testCaseResult2 = new TestCaseResult($milliTimespanMock2);
     $testCaseResult2->startTestCase();
     $testCaseResult2->stopTestCase();
     $testCaseResult2->setTestPassed();
     $unitTestResult->addTestCaseResult($testCaseResult2);
     $milliTimespanMock3 = new MilliTimespanMock();
     $testCaseResult3 = new TestCaseResult($milliTimespanMock3);
     $testCaseResult3->startTestCase();
     $testCaseResult3->stopTestCase();
     $testCaseResult3->setTestFailed();
     $unitTestResult->addTestCaseResult($testCaseResult3);
     $summary = new Summary();
     $summary->addUnitTestResult($unitTestResult);
     $expected = 33.3333;
     $actual = $summary->getPercentageFailed();
     return $this->assertEqual($expected, $actual, "", 0.001);
 }