ENHANCEMENT: Added -v / --verbose option to dev/tests/*, to make it output every single test name before it starts that test. (from r109104)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112782 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-19 00:56:02 +00:00
parent cf6907931b
commit cda6638281
2 changed files with 33 additions and 3 deletions

View File

@ -7,6 +7,16 @@
*/
class CliTestReporter extends SapphireTestReporter {
protected $verboseOutput = false;
/**
* If you set this to true, then the output for the test runner will be more verbose, listing
* every single test name.
*/
public function setVerboseOutput($verboseOutput) {
$this->verboseOutput = $verboseOutput;
}
/**
* Display error bar if it exists
*/
@ -51,6 +61,12 @@ class CliTestReporter extends SapphireTestReporter {
echo "\n";
}
public function startTest(PHPUnit_Framework_Test $test) {
parent::startTest($test);
if($this->verboseOutput) echo " - {$this->currentTest['name']}: ";
}
public function endTest( PHPUnit_Framework_Test $test, $time) {
// Status indicator, a la PHPUnit
switch($this->currentTest['status']) {
@ -63,7 +79,13 @@ class CliTestReporter extends SapphireTestReporter {
static $colCount = 0;
$colCount++;
// We don't need row breaking for verbose output; each test is on its own line
if($this->verboseOutput) {
echo "\n";
} else {
if($colCount % 80 == 0) echo " - $colCount\n";
}
parent::endTest($test, $time);
$this->writeTest($this->currentTest);

View File

@ -266,8 +266,16 @@ class TestRunner extends Controller {
restore_error_handler();
/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
if(Director::is_cli()) $reporter = new CliTestReporter();
else $reporter = new SapphireTestReporter();
if(Director::is_cli()) {
$reporter = new CliTestReporter();
// sake dev/tests/all --verbose will give you better output
if(isset($_GET['args']) && (in_array('-v', $_GET['args']) || in_array('--verbose', $_GET['args']))) {
$reporter->setVerboseOutput(true);
}
} else {
$reporter = new SapphireTestReporter();
}
self::$default_reporter->writeHeader("Sapphire Test Runner");
if (count($classList) > 1) {