From 12cade81263db4df41c0df709ed4273130e0a5dd Mon Sep 17 00:00:00 2001 From: Jeremy Thomerson Date: Mon, 3 Jun 2013 20:25:08 +0000 Subject: [PATCH] ENHANCEMENT: Do not attempt to run abstract test classes There is no reason to try to run test cases of a class that is abstract. By skipping them we allow developers to create abstract test case classes that have test functions in them. This is especially helpful when someone is testing multiple implementations of the same service interface. Most of their tests can be in the abstract class, and then they can create concrete test classes for each of their implementations and inherit all of the testing that is built into the abstract class. --- dev/TestRunner.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 741cc9a51..e9572b274 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -286,8 +286,18 @@ class TestRunner extends Controller { $skipTests = explode(',', $this->request->getVar('SkipTests')); } - $classList = array_diff($classList, $skipTests); + $abstractClasses = array(); + foreach($classList as $className) { + // Ensure that the autoloader pulls in the test class, as PHPUnit won't know how to do this. + class_exists($className); + $reflection = new ReflectionClass($className); + if ($reflection->isAbstract()) { + array_push($abstractClasses, $className); + } + } + $classList = array_diff($classList, $skipTests, $abstractClasses); + // run tests before outputting anything to the client $suite = new PHPUnit_Framework_TestSuite(); natcasesort($classList);