diff --git a/src/unit/engine/PhutilUnitTestEngine.php b/src/unit/engine/PhutilUnitTestEngine.php index 2179d5ba..1a3a110c 100644 --- a/src/unit/engine/PhutilUnitTestEngine.php +++ b/src/unit/engine/PhutilUnitTestEngine.php @@ -37,7 +37,7 @@ final class PhutilUnitTestEngine extends ArcanistBaseUnitTestEngine { $project_root = $this->getWorkingCopy()->getProjectRoot(); - $results = array(); + $test_cases = array(); foreach ($run_tests as $test_class) { $test_case = newv($test_class, array()); $test_case->setEnableCoverage($enable_coverage); @@ -48,10 +48,23 @@ final class PhutilUnitTestEngine extends ArcanistBaseUnitTestEngine { if ($this->renderer) { $test_case->setRenderer($this->renderer); } - $results[] = $test_case->run(); + $test_cases[] = $test_case; } + foreach ($test_cases as $test_case) { + $test_case->willRunTestCases($test_cases); + } + + $results = array(); + foreach ($test_cases as $test_case) { + $results[] = $test_case->run(); + } $results = array_mergev($results); + + foreach ($test_cases as $test_case) { + $test_case->didRunTestCases($test_cases); + } + return $results; } diff --git a/src/unit/engine/phutil/ArcanistPhutilTestCase.php b/src/unit/engine/phutil/ArcanistPhutilTestCase.php index b1cef23a..259aa5fe 100644 --- a/src/unit/engine/phutil/ArcanistPhutilTestCase.php +++ b/src/unit/engine/phutil/ArcanistPhutilTestCase.php @@ -310,6 +310,29 @@ abstract class ArcanistPhutilTestCase { } + /** + * This hook is invoked once, before any test cases execute. It gives you + * an opportunity to perform setup steps for the entire suite of test cases. + * + * @return void + * @task hook + */ + public function willRunTestCases(array $test_cases) { + return; + } + + + /** + * This hook is invoked once, after all test cases execute. + * + * @return void + * @task hook + */ + public function didRunTestCases(array $test_cases) { + return; + } + + /* -( Internals )---------------------------------------------------------- */