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

@ -6,6 +6,16 @@
* @subpackage testing * @subpackage testing
*/ */
class CliTestReporter extends SapphireTestReporter { 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 * Display error bar if it exists
@ -50,6 +60,12 @@ class CliTestReporter extends SapphireTestReporter {
} }
echo "\n"; 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) { public function endTest( PHPUnit_Framework_Test $test, $time) {
// Status indicator, a la PHPUnit // Status indicator, a la PHPUnit
@ -63,7 +79,13 @@ class CliTestReporter extends SapphireTestReporter {
static $colCount = 0; static $colCount = 0;
$colCount++; $colCount++;
if($colCount % 80 == 0) echo " - $colCount\n";
// 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); parent::endTest($test, $time);
$this->writeTest($this->currentTest); $this->writeTest($this->currentTest);

View File

@ -266,8 +266,16 @@ class TestRunner extends Controller {
restore_error_handler(); restore_error_handler();
/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/ /*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
if(Director::is_cli()) $reporter = new CliTestReporter(); if(Director::is_cli()) {
else $reporter = new SapphireTestReporter(); $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"); self::$default_reporter->writeHeader("Sapphire Test Runner");
if (count($classList) > 1) { if (count($classList) > 1) {