/** * @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(); } } }