コード例 #1
0
ファイル: Tester.php プロジェクト: konecnyjakub/mytester
 /**
  * Execute all tests
  * 
  * @return void
  */
 function execute()
 {
     Environment::setup();
     Environment::printInfo();
     $failed = false;
     foreach ($this->suits as $suit) {
         /** @var TestCase $suit */
         $suit = new $suit[0]();
         $result = $suit->run();
         if (!$result) {
             $failed = true;
         }
     }
     Environment::printLine("");
     foreach (Environment::getSkipped() as $skipped) {
         if ($skipped["reason"]) {
             $reason = ": {$skipped["reason"]}";
         } else {
             $reason = "";
         }
         Environment::printLine("Skipped {$skipped["name"]}{$reason}");
     }
     if ($failed) {
         Environment::printLine("Failed");
         Environment::printLine("");
         $files = Finder::findFiles("*.errors")->in(\getTestsDirectory());
         foreach ($files as $name => $file) {
             Environment::printLine("--- " . substr($file->getBaseName(), 0, -7));
             echo file_get_contents($name);
         }
     } else {
         Environment::printLine("OK");
     }
     exit((int) $failed);
 }
コード例 #2
0
ファイル: Job.php プロジェクト: konecnyjakub/mytester
 /**
  * Executes the task
  * 
  * @return void
  */
 function execute()
 {
     Environment::resetCounter();
     Environment::setShouldFail($this->shouldFail);
     if ($this->skip) {
         $this->result = "skipped";
         Environment::addSkipped($this->name, !is_bool($this->skip) ? $this->skip : "");
     } else {
         ob_start();
         if (isset($this->callback)) {
             call_user_func_array($this->callback, $this->params);
         }
         $output = ob_get_clean();
         $failed = Environment::checkFailed($output);
         if ($failed and !$this->shouldFail) {
             $this->result = "failed";
         }
         if (strlen($output) and $this->result === "failed") {
             file_put_contents(\getTestsDirectory() . "/{$this->name}.errors", $output);
         }
     }
     Environment::setShouldFail(false);
 }