/** * Factory constructor * * @param string $testFile * @param string Meta information of the testfile */ function __construct($testFile, $ParseTestFile) { $this->fileExt = agnosUtil::getFileExtension($testFile); if ($this->fileExt !== false) { $this->testFile = $testFile; $this->ParseTestFile = $ParseTestFile; } }
/** * Displays overall test summary * * @param timestamp Time tests started * @param timestatmp Time tests ended * @param integer Total number of tests found * @param array Array of failed tests */ public function testSummary($_timeStart, $timeEnd, $totalTestCases, $failedTest) { $countFailed = sizeof($failedTest['FAILED']); $countSkipped = sizeof($failedTest['SKIPPED']); $countPassed = $totalTestCases - ($countFailed + $countSkipped); $avgTime = $timeEnd - $_timeStart; $timeStart = @date('Y-m-d H:i:s', $_timeStart); $timeEnd = @date('Y-m-d H:i:s', $timeEnd); $date = @date('D, Y-m-d H:i:s a', $_timeStart); $uniqid = @date('Y-m-d-H:i:s', $_timeStart); $filename = "agnos-report-{$uniqid}.txt"; $testSummary = "\n TEST RESULT SUMMARY\n Copyright (C) 2008 agnos v0.0.1\n \nFilename : {$filename}\nDate : {$date}\n--------------------------------------------------------------------------------\nTotal Tests : {$totalTestCases}\nPassed : {$countPassed}\nFailed : {$countFailed}\nSkipped : {$countSkipped}\n--------------------------------------------------------------------------------\n\nTIMESTAMP\n--------------------------------------------------------------------------------\nStarted : {$timeStart}\nEnded : {$timeEnd}\nTotal time : {$avgTime} seconds\n--------------------------------------------------------------------------------\n"; if ($countFailed >= 1) { $contents = agnosUtil::arrayToString($failedTest['FAILED'], 'name'); $failedTestReport = "\nFAILED TESTS REPORT\n--------------------------------------------------------------------------------\n{$contents}\n--------------------------------------------------------------------------------\n"; $testSummary .= $failedTestReport; } agnosConsole::message($testSummary); if (agnosFileDir::createDir('agnos-reports')) { agnosUtil::saveText('agnos-reports' . DIRECTORY_SEPARATOR . $filename, $testSummary); } return true; }
/* * See help for additional informations */ $fileToTests = null; $dirToTests = null; # -f if ($isFileTest) { if (($fileToTests = agnosUtil::setUpTestFile($testByFile)) === false) { exit; } } # -r if ($isDirTest) { if (($dirToTests = agnosUtil::findFiles($testByDir)) === false) { exit; } } /* * run all tests */ if (($tests = agnosUtil::mergeTests($fileToTests, $dirToTests)) !== false) { $do =& new agnosTester(); $do->testRunAll($tests); } } else { echo "\n{$help}\n"; } } else { echo "\n{$help}\n"; exit; }