/** * @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(); } } }
/** * @throws BuildException */ private function execute($suite) { $runner = new PHPUnitTestRunner($suite, $this->project, $this->groups, $this->excludeGroups); $runner->setCodecoverage($this->codecoverage); foreach ($this->formatters as $fe) { $formatter = $fe->getFormatter(); $runner->addFormatter($formatter); } $runner->run(); $retcode = $runner->getRetCode(); if ($retcode == PHPUnitTestRunner::ERRORS) { if ($this->errorproperty) { $this->project->setNewProperty($this->errorproperty, true); } if ($this->haltonerror) { $this->testfailed = true; } } elseif ($retcode == PHPUnitTestRunner::FAILURES) { if ($this->failureproperty) { $this->project->setNewProperty($this->failureproperty, true); } if ($this->haltonfailure) { $this->testfailed = true; } } elseif ($retcode == PHPUnitTestRunner::INCOMPLETES) { if ($this->incompleteproperty) { $this->project->setNewProperty($this->incompleteproperty, true); } if ($this->haltonincomplete) { $this->testfailed = true; } } elseif ($retcode == PHPUnitTestRunner::SKIPPED) { if ($this->skippedproperty) { $this->project->setNewProperty($this->skippedproperty, true); } if ($this->haltonskipped) { $this->testfailed = true; } } }
/** * @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->getLastErrorMessage(); } } 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->getLastIncompleteMessage(); } } elseif ($retcode == PHPUnitTestRunner::SKIPPED) { if ($this->skippedproperty) { $this->project->setNewProperty($this->skippedproperty, true); } if ($this->haltonskipped) { $this->testfailed = true; $this->testfailuremessage = $runner->getLastSkippedMessage(); } } }
/** * @throws BuildException */ private function execute($suite) { $runner = new PHPUnitTestRunner($suite, $this->project); $runner->setCodecoverage($this->codecoverage); foreach ($this->formatters as $fe) { $formatter = $fe->getFormatter(); $runner->addFormatter($formatter); } $runner->run(); $retcode = $runner->getRetCode(); if ($retcode == PHPUnitTestRunner::ERRORS) { if ($this->errorproperty) { $this->project->setNewProperty($this->errorproperty, true); } if ($this->haltonerror) { $this->testfailed = true; } } elseif ($retcode == PHPUnitTestRunner::FAILURES) { if ($this->failureproperty) { $this->project->setNewProperty($this->failureproperty, true); } if ($this->haltonfailure) { $this->testfailed = true; } } }
/** * @throws BuildException */ private function execute($test) { $runner = new PHPUnitTestRunner($this->project, $this->groups, $this->excludeGroups); $runner->setCodecoverage($this->codecoverage); foreach ($this->formatters as $fe) { $formatter = $fe->getFormatter(); $runner->addFormatter($formatter); } /* Invoke the 'suite' method when it exists in the test class */ $testClass = new ReflectionClass($test); if ($testClass->hasMethod('suite')) { $suiteMethod = $testClass->getMethod('suite'); $suite = $suiteMethod->invoke(NULL, $testClass->getName()); } else { $suite = new PHPUnit_Framework_TestSuite($test); } $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(); } } }