forked from openid/php-openid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[project @ Add a text-based test harness]
- Loading branch information
Josh Hoyt
committed
Dec 24, 2005
1 parent
d6c42a8
commit 6accef2
Showing
3 changed files
with
109 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
require_once('Tests/TestDriver.php'); | ||
require_once('PHPUnit/TestResult.php'); | ||
|
||
class TextTestResult extends PHPUnit_TestResult { | ||
function addError(&$test, &$t) { | ||
parent::addError($test, $t); | ||
echo "E"; | ||
} | ||
|
||
function addFailure(&$test, &$t) { | ||
parent::addFailure($test, $t); | ||
echo "F"; | ||
} | ||
|
||
function addPassedTest(&$test) { | ||
parent::addPassedTest($test); | ||
echo "."; | ||
} | ||
|
||
function dumpBadResults() { | ||
foreach ($this->failures() as $failure) { | ||
echo $failure->toString(); | ||
} | ||
|
||
foreach ($this->errors() as $failure) { | ||
echo $failure->toString(); | ||
} | ||
} | ||
} | ||
|
||
function microtime_float() | ||
{ | ||
list($usec, $sec) = explode(" ", microtime()); | ||
return ((float)$usec + (float)$sec); | ||
} | ||
|
||
$suites = loadSuite(); | ||
|
||
$totals = array( | ||
'run' => 0, | ||
'error' => 0, | ||
'failure' => 0, | ||
'time' => 0 | ||
); | ||
|
||
foreach ($suites as $suite) { | ||
$name = $suite->getName(); | ||
echo "========================================== | ||
Test suite: $name | ||
------------------------------------------ | ||
"; | ||
|
||
$result = new TextTestResult(); | ||
$before = microtime_float(); | ||
$suite->run($result); | ||
$after = microtime_float(); | ||
|
||
$run = $result->runCount(); | ||
$error = $result->errorCount(); | ||
$failure = $result->failureCount(); | ||
$delta = $after - $before; | ||
$totals['run'] += $run; | ||
$totals['error'] += $error; | ||
$totals['failure'] += $failure; | ||
$totals['time'] += $delta; | ||
$human_delta = round($delta, 3); | ||
echo "\nRan $run tests in $human_delta seconds"; | ||
if ($error || $failure) { | ||
echo " with $error errors, $failure failures"; | ||
} | ||
echo " | ||
========================================== | ||
"; | ||
} | ||
|
||
$before = microtime_float(); | ||
$run = $totals['run']; | ||
$error = $totals['error']; | ||
$failure = $totals['failure']; | ||
$time = round($totals['time'], 3); | ||
echo "Ran a total of $run tests in $time seconds with $error errors, $failure failures\n"; | ||
if ($totals['error'] || $totals['failure']) { | ||
exit(1); | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
require_once('Tests/TestDriver.php'); | ||
|
||
$suites = loadSuite(); | ||
|
||
// Create and run the user interface | ||
$gui = new PHPUnit_GUI_HTML(); | ||
$gui->addSuites($suites); | ||
$gui->show(); | ||
|
||
?> |