From dd12b72f9a0336eea5efa845e815903eb9039d9e Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Mon, 13 Jan 2014 12:35:33 -0800 Subject: [PATCH] Added test namespace field to `ArcanistUnitTestResult` Summary: See https://github.com/facebook/libphutil/issues/34 Test Plan: Run `arc unit` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7952 --- src/unit/ArcanistUnitTestResult.php | 10 ++++++++++ src/unit/engine/phutil/ArcanistPhutilTestCase.php | 1 + src/unit/renderer/ArcanistUnitConsoleRenderer.php | 9 ++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/unit/ArcanistUnitTestResult.php b/src/unit/ArcanistUnitTestResult.php index a004ee68..a1cd34a8 100644 --- a/src/unit/ArcanistUnitTestResult.php +++ b/src/unit/ArcanistUnitTestResult.php @@ -14,6 +14,7 @@ final class ArcanistUnitTestResult { const RESULT_UNSOUND = 'unsound'; const RESULT_POSTPONED = 'postponed'; + private $namespace; private $name; private $link; private $result; @@ -22,6 +23,15 @@ final class ArcanistUnitTestResult { private $extraData; private $coverage; + public function setNamespace($namespace) { + $this->namespace = $namespace; + return $this; + } + + public function getNamespace() { + return $this->namespace; + } + public function setName($name) { $this->name = $name; return $this; diff --git a/src/unit/engine/phutil/ArcanistPhutilTestCase.php b/src/unit/engine/phutil/ArcanistPhutilTestCase.php index d88e5e93..2825ebcd 100644 --- a/src/unit/engine/phutil/ArcanistPhutilTestCase.php +++ b/src/unit/engine/phutil/ArcanistPhutilTestCase.php @@ -396,6 +396,7 @@ abstract class ArcanistPhutilTestCase { $result = new ArcanistUnitTestResult(); $result->setCoverage($coverage); + $result->setNamespace(get_class($this)); $result->setName($this->runningTest); $result->setLink($this->getLink($this->runningTest)); $result->setResult($test_result); diff --git a/src/unit/renderer/ArcanistUnitConsoleRenderer.php b/src/unit/renderer/ArcanistUnitConsoleRenderer.php index a20265f0..4ab444bd 100644 --- a/src/unit/renderer/ArcanistUnitConsoleRenderer.php +++ b/src/unit/renderer/ArcanistUnitConsoleRenderer.php @@ -12,10 +12,17 @@ final class ArcanistUnitConsoleRenderer extends ArcanistUnitRenderer { if ($result_code == ArcanistUnitTestResult::RESULT_PASS) { $duration = ' '.$this->formatTestDuration($result->getDuration()); } + + $test_name = $result->getName(); + $test_namespace = $result->getNamespace(); + if (strlen($test_namespace)) { + $test_name = $test_namespace.'::'.$test_name; + } + $return = sprintf( " %s %s\n", $this->getFormattedResult($result->getResult()).$duration, - $result->getName()); + $test_name); if ($result_code != ArcanistUnitTestResult::RESULT_PASS) { $return .= $result->getUserData()."\n";