Skip to content

Commit

Permalink
ENHANCEMENT you can now do coverage tests of single/multiple tests, o…
Browse files Browse the repository at this point in the history
…r entire modules (from r99954)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105544 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed May 25, 2010
1 parent cd66429 commit 3a19dc0
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions dev/TestRunner.php
Expand Up @@ -39,7 +39,9 @@ class TestRunner extends Controller {

static $url_handlers = array(
'' => 'browse',
'coverage' => 'coverage',
'coverage/module/$ModuleName' => 'coverageModule',
'coverage/$TestCase' => 'coverageOnly',
'coverage' => 'coverageAll',
'startsession' => 'startsession',
'endsession' => 'endsession',
'cleanupdb' => 'cleanupdb',
Expand Down Expand Up @@ -80,7 +82,7 @@ public function Link() {
* Run test classes that should be run with every commit.
* Currently excludes PhpSyntaxTest
*/
function all() {
function all($coverage = false) {
ManifestBuilder::load_test_manifest();
$tests = ClassInfo::subclassesFor('SapphireTest');
array_shift($tests);
Expand All @@ -94,7 +96,7 @@ function all() {
if(!$reflection->isInstantiable()) unset($tests[$class]);
}

$this->runTests($tests);
$this->runTests($tests, $coverage);
}

/**
Expand Down Expand Up @@ -147,15 +149,27 @@ function browse() {
self::$default_reporter->writeFooter();
}

function coverage() {
ManifestBuilder::load_test_manifest();
ManifestBuilder::load_all_classes();

$tests = ClassInfo::subclassesFor('SapphireTest');
array_shift($tests);
unset($tests['FunctionalTest']);
/**
* Run a coverage test across all modules
*/
function coverageAll() {
ManifestBuilder::load_all_classes();
$this->all(true);
}

/**
* Run only a single coverage test class or a comma-separated list of tests
*/
function coverageOnly($request) {
$this->only($request, true);
}

$this->runTests($tests, 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() {
Expand All @@ -165,7 +179,7 @@ function cleanupdb() {
/**
* 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();
if($request->param('TestCase') == 'all') {
$this->all();
Expand All @@ -177,15 +191,15 @@ function only($request) {
}
}

$this->runTests($classNames);
$this->runTests($classNames, $coverage);
}
}

/**
* Run tests for one or more "modules".
* A module is generally a toplevel folder, e.g. "mysite" or "sapphire".
*/
function module($request) {
function module($request, $coverage = false) {
ManifestBuilder::load_test_manifest();
$classNames = array();
$moduleNames = explode(',', $request->param('ModuleName'));
Expand All @@ -198,7 +212,7 @@ function module($request) {
}
}

$this->runTests($classNames);
$this->runTests($classNames, $coverage);
}

/**
Expand Down

0 comments on commit 3a19dc0

Please sign in to comment.