Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * Returns a canonical absolute path of the test file(s).
  *
  * This function validates if the file really exist or is not a directory 
  * 
  * @param   mixed   An array of $path or a string $path only.
  * @return  mixed   An array of $path or a string $path only.
  *  
  * @access  public  
  */
 public function setUpTestFile($filename)
 {
     if (is_array($filename)) {
         foreach ($filename as $file) {
             $fp = agnosFileDir::getFullPath($file);
             if (!agnosFileDir::isValidFile($fp)) {
                 agnosConsole::realTime("FATAL", "Invalid or file not found", $file);
                 return false;
             }
             $canonicalPath[] = $fp;
         }
         return $canonicalPath;
     } else {
         $fp = agnosFileDir::getFullPath($filename);
         if (agnosFileDir::isValidFile($fp)) {
             return $fp;
         }
     }
     agnosConsole::realTime("FATAL", "Invalid file found", $filename);
     return false;
 }