]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Display number of assertions in unit test details
authorvrana <jakubv@fb.com>
Sun, 17 Jun 2012 15:13:40 +0000 (08:13 -0700)
committervrana <jakubv@fb.com>
Sun, 17 Jun 2012 20:39:46 +0000 (13:39 -0700)
Test Plan: Show Full Unit Results on this diff.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D2777

scripts/__init_script__.php
src/unit/engine/phutil/ArcanistPhutilTestCase.php

index 70708eca1563697d81d96198b6033510c46cfdc7..38c6e4edff75de4f002db1eb11c29cf3acb83a1b 100644 (file)
@@ -62,6 +62,11 @@ PhutilTranslator::getInstance()
     ),
 
     'line(s)' => array('line', 'lines'),
+
+    '%d assertion(s) passed.' => array(
+      '%d assertion passed.',
+      '%d assertions passed.',
+    ),
   ));
 
 phutil_load_library(dirname(dirname(__FILE__)).'/src/');
index cea863d01392327425f0da27b5f7af5e8daa5b62..e0ec47d8643400f9a5c00a7f1adecd9b548e7bc9 100644 (file)
@@ -28,6 +28,7 @@
  */
 abstract class ArcanistPhutilTestCase {
 
+  private $assertions = 0;
   private $runningTest;
   private $testStartTime;
   private $results = array();
@@ -59,6 +60,7 @@ abstract class ArcanistPhutilTestCase {
    */
   final protected function assertEqual($expect, $result, $message = null) {
     if ($expect === $result) {
+      $this->assertions++;
       return;
     }
 
@@ -422,6 +424,7 @@ abstract class ArcanistPhutilTestCase {
       $name = $method->getName();
       if (preg_match('/^test/', $name)) {
         $this->runningTest = $name;
+        $this->assertions = 0;
         $this->testStartTime = microtime(true);
 
         try {
@@ -433,7 +436,7 @@ abstract class ArcanistPhutilTestCase {
             call_user_func_array(
               array($this, $name),
               array());
-            $this->passTest("All assertions passed.");
+            $this->passTest(pht('%d assertion(s) passed.', $this->assertions));
           } catch (Exception $ex) {
             $test_exception = $ex;
           }