mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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.
This commit is contained in:
parent
e137d9e2f0
commit
12cade8126
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user