Added TestRunner/only/(classname) option

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@40230 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2007-08-16 06:35:27 +00:00
parent 35a87e84b3
commit 6e335ae8a7

View File

@ -16,22 +16,44 @@ require_once 'PHPUnit/TextUI/TestRunner.php';
* Controller that executes PHPUnit tests * Controller that executes PHPUnit tests
*/ */
class TestRunner extends Controller { class TestRunner extends Controller {
/**
* Run all test classes
*/
function index() { function index() {
ManifestBuilder::includeEverything(); ManifestBuilder::includeEverything();
$tests = ClassInfo::subclassesFor('SapphireTest'); $tests = ClassInfo::subclassesFor('SapphireTest');
array_shift($tests); array_shift($tests);
$this->runTests($tests);
}
/**
* Run only a single test class
*/
function only() {
$className = $this->urlParams['ID'];
if(class_exists($className)) {
$this->runTests(array($className));
} else {
echo "Class '$className' not found";
}
}
function runTests($classList) {
echo "<h1>Sapphire PHPUnit Test Runner</h1>"; echo "<h1>Sapphire PHPUnit Test Runner</h1>";
echo "<p>Discovered the following subclasses of SapphireTest for testing: " . implode(", ", $tests) . "</p>"; echo "<p>Using the following subclasses of SapphireTest for testing: " . implode(", ", $classList) . "</p>";
echo "<pre>"; echo "<pre>";
$suite = new PHPUnit_Framework_TestSuite(); $suite = new PHPUnit_Framework_TestSuite();
foreach($tests as $test) { foreach($classList as $className) {
$suite->addTest(new PHPUnit_Framework_TestSuite($test)); $suite->addTest(new PHPUnit_Framework_TestSuite($className));
} }
PHPUnit_TextUI_TestRunner::run($suite/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/); /*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
PHPUnit_TextUI_TestRunner::run($suite);
} }
} }