From: Aurelijus Date: Tue, 22 May 2012 15:24:01 +0000 (+0200) Subject: PHPUnit test name handling improvements X-Git-Tag: conduit-6~314 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6e87de7304ce384a3166d2cc56c29f0876f7bbae;p=arcanist.git PHPUnit test name handling improvements Summary: Better test name handling for tests with data sets. Instead of showing test name with full data set, show it's id/name, e.g. `testConstructor with data set #1` Test Plan: - Try running tests with data sets Reviewers: epriestley Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2535 --- diff --git a/src/unit/engine/phpunit/PhpunitTestEngine.php b/src/unit/engine/phpunit/PhpunitTestEngine.php index a9f1ba4b..bcbd0a5e 100644 --- a/src/unit/engine/phpunit/PhpunitTestEngine.php +++ b/src/unit/engine/phpunit/PhpunitTestEngine.php @@ -188,7 +188,14 @@ final class PhpunitTestEngine extends ArcanistBaseUnitTestEngine { } } - $name = substr($event->test, strlen($event->suite) + 2); + $pos = strpos($event->suite, '::'); + if ($pos === false) { + $name = substr($event->test, strlen($event->suite) + 2); + } else { + $name = substr($event->test, $pos + 2); + $name = preg_replace('/ \(array\(.*\)\)/', '', $name); + } + $result = new ArcanistUnitTestResult(); $result->setName($name); $result->setResult($status); @@ -212,7 +219,12 @@ final class PhpunitTestEngine extends ArcanistBaseUnitTestEngine { private function readCoverage($path) { $test_results = Filesystem::readFile($path); if (empty($test_results)) { - throw new Exception('Clover coverage XML report file is empty'); + throw new Exception('Clover coverage XML report file is empty, ' + . 'it probably means that phpunit failed to run tests. ' + . 'Try running arc unit with --trace option and then run ' + . 'generated phpunit command yourself, you might get the ' + . 'answer.' + ); } $coverage_dom = new DOMDocument();