mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Add willRunTestCases / didRunTestCases hooks
Summary: These hooks allow test cases to build shared resources -- notably, database fixtures. Test Plan: See next diff. Reviewers: vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D5258
This commit is contained in:
parent
5296bf529f
commit
c827490708
2 changed files with 38 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 )---------------------------------------------------------- */
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue