1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Display number of assertions in unit test details

Test Plan: Show Full Unit Results on this diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2777
This commit is contained in:
vrana 2012-06-17 08:13:40 -07:00
parent 7c3c1e88bd
commit 23b3dd7e95
2 changed files with 9 additions and 1 deletions

View file

@ -62,6 +62,11 @@ PhutilTranslator::getInstance()
), ),
'line(s)' => array('line', 'lines'), 'line(s)' => array('line', 'lines'),
'%d assertion(s) passed.' => array(
'%d assertion passed.',
'%d assertions passed.',
),
)); ));
phutil_load_library(dirname(dirname(__FILE__)).'/src/'); phutil_load_library(dirname(dirname(__FILE__)).'/src/');

View file

@ -28,6 +28,7 @@
*/ */
abstract class ArcanistPhutilTestCase { abstract class ArcanistPhutilTestCase {
private $assertions = 0;
private $runningTest; private $runningTest;
private $testStartTime; private $testStartTime;
private $results = array(); private $results = array();
@ -59,6 +60,7 @@ abstract class ArcanistPhutilTestCase {
*/ */
final protected function assertEqual($expect, $result, $message = null) { final protected function assertEqual($expect, $result, $message = null) {
if ($expect === $result) { if ($expect === $result) {
$this->assertions++;
return; return;
} }
@ -422,6 +424,7 @@ abstract class ArcanistPhutilTestCase {
$name = $method->getName(); $name = $method->getName();
if (preg_match('/^test/', $name)) { if (preg_match('/^test/', $name)) {
$this->runningTest = $name; $this->runningTest = $name;
$this->assertions = 0;
$this->testStartTime = microtime(true); $this->testStartTime = microtime(true);
try { try {
@ -433,7 +436,7 @@ abstract class ArcanistPhutilTestCase {
call_user_func_array( call_user_func_array(
array($this, $name), array($this, $name),
array()); array());
$this->passTest("All assertions passed."); $this->passTest(pht('%d assertion(s) passed.', $this->assertions));
} catch (Exception $ex) { } catch (Exception $ex) {
$test_exception = $ex; $test_exception = $ex;
} }