/**
  * @param $suite
  */
 protected function execute($suite)
 {
     $runner = new PHPUnitTestRunner($this->project, $this->groups, $this->excludeGroups, $this->processIsolation);
     if ($this->codecoverage) {
         /**
          * Add some defaults to the PHPUnit filter
          */
         $pwd = dirname(__FILE__);
         $path = realpath($pwd . '/../../../');
         $filter = new PHP_CodeCoverage_Filter();
         $filter->addDirectoryToBlacklist($path);
         $runner->setCodecoverage(new PHP_CodeCoverage(null, $filter));
     }
     $runner->setUseCustomErrorHandler($this->usecustomerrorhandler);
     foreach ($this->listeners as $listener) {
         $runner->addListener($listener);
     }
     foreach ($this->formatters as $fe) {
         $formatter = $fe->getFormatter();
         if ($fe->getUseFile()) {
             $destFile = new PhingFile($fe->getToDir(), $fe->getOutfile());
             $writer = new FileWriter($destFile->getAbsolutePath());
             $formatter->setOutput($writer);
         } else {
             $formatter->setOutput($this->getDefaultOutput());
         }
         $runner->addFormatter($formatter);
         $formatter->startTestRun();
     }
     $runner->run($suite);
     foreach ($this->formatters as $fe) {
         $formatter = $fe->getFormatter();
         $formatter->endTestRun();
     }
     if ($runner->hasErrors()) {
         if ($this->errorproperty) {
             $this->project->setNewProperty($this->errorproperty, true);
         }
         if ($this->haltonerror) {
             $this->testfailed = true;
             $this->testfailuremessage = $runner->getLastErrorMessage();
         }
     }
     if ($runner->hasFailures()) {
         if ($this->failureproperty) {
             $this->project->setNewProperty($this->failureproperty, true);
         }
         if ($this->haltonfailure) {
             $this->testfailed = true;
             $this->testfailuremessage = $runner->getLastFailureMessage();
         }
     }
     if ($runner->hasIncomplete()) {
         if ($this->incompleteproperty) {
             $this->project->setNewProperty($this->incompleteproperty, true);
         }
         if ($this->haltonincomplete) {
             $this->testfailed = true;
             $this->testfailuremessage = $runner->getLastIncompleteMessage();
         }
     }
     if ($runner->hasSkipped()) {
         if ($this->skippedproperty) {
             $this->project->setNewProperty($this->skippedproperty, true);
         }
         if ($this->haltonskipped) {
             $this->testfailed = true;
             $this->testfailuremessage = $runner->getLastSkippedMessage();
         }
     }
 }
Пример #2
0
 /**
  * @throws BuildException
  */
 protected function execute($suite)
 {
     $runner = new PHPUnitTestRunner($this->project, $this->groups, $this->excludeGroups);
     $runner->setCodecoverage($this->codecoverage);
     $runner->setUseCustomErrorHandler($this->usecustomerrorhandler);
     foreach ($this->formatters as $fe) {
         $formatter = $fe->getFormatter();
         $runner->addFormatter($formatter);
     }
     $runner->run($suite);
     $retcode = $runner->getRetCode();
     if ($retcode == PHPUnitTestRunner::ERRORS) {
         if ($this->errorproperty) {
             $this->project->setNewProperty($this->errorproperty, true);
         }
         if ($this->haltonerror) {
             $this->testfailed = true;
             $this->testfailuremessage = $runner->getLastFailureMessage();
         }
     } elseif ($retcode == PHPUnitTestRunner::FAILURES) {
         if ($this->failureproperty) {
             $this->project->setNewProperty($this->failureproperty, true);
         }
         if ($this->haltonfailure) {
             $this->testfailed = true;
             $this->testfailuremessage = $runner->getLastFailureMessage();
         }
     } elseif ($retcode == PHPUnitTestRunner::INCOMPLETES) {
         if ($this->incompleteproperty) {
             $this->project->setNewProperty($this->incompleteproperty, true);
         }
         if ($this->haltonincomplete) {
             $this->testfailed = true;
             $this->testfailuremessage = $runner->getLastFailureMessage();
         }
     } elseif ($retcode == PHPUnitTestRunner::SKIPPED) {
         if ($this->skippedproperty) {
             $this->project->setNewProperty($this->skippedproperty, true);
         }
         if ($this->haltonskipped) {
             $this->testfailed = true;
             $this->testfailuremessage = $runner->getLastFailureMessage();
         }
     }
 }