3 class SeleniumTestListener
implements PHPUnit_Framework_TestListener
{
6 private $tests_failed = 0;
8 public function __construct( $loggerInstance ) {
9 $this->logger
= $loggerInstance;
12 public function addError( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
13 $this->logger
->write( 'Error: ' . $e->getMessage() );
14 $this->tests_failed++
;
17 public function addFailure( PHPUnit_Framework_Test
$test, PHPUnit_Framework_AssertionFailedError
$e, $time ) {
18 $this->logger
->write( 'Failed: ' . $e->getMessage() );
19 $this->tests_failed++
;
22 public function addIncompleteTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
23 $this->logger
->write( 'Incomplete.' );
24 $this->tests_failed++
;
27 public function addSkippedTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
28 $this->logger
->write( 'Skipped.' );
29 $this->tests_failed++
;
32 public function startTest( PHPUnit_Framework_Test
$test ) {
34 'Testing ' . $test->getName() . ' ... ',
35 SeleniumTestSuite
::CONTINUE_LINE
39 public function endTest( PHPUnit_Framework_Test
$test, $time ) {
40 if ( !$test->hasFailed() ) {
41 $this->logger
->write( 'OK', SeleniumTestSuite
::RESULT_OK
);
46 public function startTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
47 $this->logger
->write( 'Testsuite ' . $suite->getName() . ' started.' );
49 $this->tests_failed
= 0;
52 public function endTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
53 $this->logger
->write( 'Testsuite ' . $suite->getName() . ' ended.' );
54 if ( $this->tests_ok
> 0 ||
$this->tests_failed
> 0 ) {
55 $this->logger
->write( ' OK: ' . $this->tests_ok
. ' Failed: ' . $this->tests_failed
);
58 $this->tests_failed
= 0;
61 public function statusMessage( $message ) {
62 $this->logger
->write( $message );