mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT you can now do coverage tests of single/multiple tests, or entire modules (from r99954)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105544 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
cd66429be7
commit
3a19dc08a3
@ -39,7 +39,9 @@ class TestRunner extends Controller {
|
|||||||
|
|
||||||
static $url_handlers = array(
|
static $url_handlers = array(
|
||||||
'' => 'browse',
|
'' => 'browse',
|
||||||
'coverage' => 'coverage',
|
'coverage/module/$ModuleName' => 'coverageModule',
|
||||||
|
'coverage/$TestCase' => 'coverageOnly',
|
||||||
|
'coverage' => 'coverageAll',
|
||||||
'startsession' => 'startsession',
|
'startsession' => 'startsession',
|
||||||
'endsession' => 'endsession',
|
'endsession' => 'endsession',
|
||||||
'cleanupdb' => 'cleanupdb',
|
'cleanupdb' => 'cleanupdb',
|
||||||
@ -80,7 +82,7 @@ class TestRunner extends Controller {
|
|||||||
* Run test classes that should be run with every commit.
|
* Run test classes that should be run with every commit.
|
||||||
* Currently excludes PhpSyntaxTest
|
* Currently excludes PhpSyntaxTest
|
||||||
*/
|
*/
|
||||||
function all() {
|
function all($coverage = false) {
|
||||||
ManifestBuilder::load_test_manifest();
|
ManifestBuilder::load_test_manifest();
|
||||||
$tests = ClassInfo::subclassesFor('SapphireTest');
|
$tests = ClassInfo::subclassesFor('SapphireTest');
|
||||||
array_shift($tests);
|
array_shift($tests);
|
||||||
@ -94,7 +96,7 @@ class TestRunner extends Controller {
|
|||||||
if(!$reflection->isInstantiable()) unset($tests[$class]);
|
if(!$reflection->isInstantiable()) unset($tests[$class]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->runTests($tests);
|
$this->runTests($tests, $coverage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,15 +149,27 @@ class TestRunner extends Controller {
|
|||||||
self::$default_reporter->writeFooter();
|
self::$default_reporter->writeFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function coverage() {
|
/**
|
||||||
ManifestBuilder::load_test_manifest();
|
* Run a coverage test across all modules
|
||||||
ManifestBuilder::load_all_classes();
|
*/
|
||||||
|
function coverageAll() {
|
||||||
$tests = ClassInfo::subclassesFor('SapphireTest');
|
ManifestBuilder::load_all_classes();
|
||||||
array_shift($tests);
|
$this->all(true);
|
||||||
unset($tests['FunctionalTest']);
|
}
|
||||||
|
|
||||||
$this->runTests($tests, true);
|
/**
|
||||||
|
* Run only a single coverage test class or a comma-separated list of tests
|
||||||
|
*/
|
||||||
|
function coverageOnly($request) {
|
||||||
|
$this->only($request, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run coverage tests for one or more "modules".
|
||||||
|
* A module is generally a toplevel folder, e.g. "mysite" or "sapphire".
|
||||||
|
*/
|
||||||
|
function coverageModule($request) {
|
||||||
|
$this->module($request, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupdb() {
|
function cleanupdb() {
|
||||||
@ -165,7 +179,7 @@ class TestRunner extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Run only a single test class or a comma-separated list of tests
|
* Run only a single test class or a comma-separated list of tests
|
||||||
*/
|
*/
|
||||||
function only($request) {
|
function only($request, $coverage = false) {
|
||||||
ManifestBuilder::load_test_manifest();
|
ManifestBuilder::load_test_manifest();
|
||||||
if($request->param('TestCase') == 'all') {
|
if($request->param('TestCase') == 'all') {
|
||||||
$this->all();
|
$this->all();
|
||||||
@ -177,7 +191,7 @@ class TestRunner extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->runTests($classNames);
|
$this->runTests($classNames, $coverage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +199,7 @@ class TestRunner extends Controller {
|
|||||||
* Run tests for one or more "modules".
|
* Run tests for one or more "modules".
|
||||||
* A module is generally a toplevel folder, e.g. "mysite" or "sapphire".
|
* A module is generally a toplevel folder, e.g. "mysite" or "sapphire".
|
||||||
*/
|
*/
|
||||||
function module($request) {
|
function module($request, $coverage = false) {
|
||||||
ManifestBuilder::load_test_manifest();
|
ManifestBuilder::load_test_manifest();
|
||||||
$classNames = array();
|
$classNames = array();
|
||||||
$moduleNames = explode(',', $request->param('ModuleName'));
|
$moduleNames = explode(',', $request->param('ModuleName'));
|
||||||
@ -198,7 +212,7 @@ class TestRunner extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->runTests($classNames);
|
$this->runTests($classNames, $coverage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user