mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Allowing test runs per module (top-level folder), e.g. sake dev/tests/module/sapphire
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@80645 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
8ae9db13c0
commit
504980ce4d
@ -25,6 +25,8 @@ require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
/**
|
||||
* Controller that executes PHPUnit tests.
|
||||
*
|
||||
* See {@link browse()} output for generic usage instructions.
|
||||
*
|
||||
* @package sapphire
|
||||
* @subpackage testing
|
||||
*/
|
||||
@ -38,6 +40,7 @@ class TestRunner extends Controller {
|
||||
'startsession' => 'startsession',
|
||||
'endsession' => 'endsession',
|
||||
'cleanupdb' => 'cleanupdb',
|
||||
'module/$ModuleName' => 'module',
|
||||
'$TestCase' => 'only',
|
||||
);
|
||||
|
||||
@ -87,6 +90,7 @@ class TestRunner extends Controller {
|
||||
$relativeLink = Director::makeRelative($this->Link());
|
||||
echo "sake {$relativeLink}all: Run all " . count($tests) . " tests\n";
|
||||
echo "sake {$relativeLink}coverage: Runs all tests and make test coverage report\n";
|
||||
echo "sake {$relativeLink}module/<modulename>: Runs all tests in a module folder\n";
|
||||
foreach ($tests as $test) {
|
||||
echo "sake {$relativeLink}$test: Run $test\n";
|
||||
}
|
||||
@ -136,6 +140,23 @@ class TestRunner extends Controller {
|
||||
$this->runTests($classNames);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run tests for one or more "modules".
|
||||
* A module is generally a toplevel folder, e.g. "mysite" or "sapphire".
|
||||
*/
|
||||
function module($request) {
|
||||
$classNames = array();
|
||||
$moduleNames = explode(',', $request->param('ModuleName'));
|
||||
foreach($moduleNames as $moduleName) {
|
||||
$classesForModule = ClassInfo::classes_for_folder($moduleName);
|
||||
if($classesForModule) foreach($classesForModule as $class) {
|
||||
if(is_subclass_of($class, 'SapphireTest')) $classNames[] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
$this->runTests($classNames);
|
||||
}
|
||||
|
||||
function runTests($classList, $coverage = false) {
|
||||
// XDEBUG seem to cause problems with test execution :-(
|
||||
|
Loading…
x
Reference in New Issue
Block a user