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 )
19 $this->logger
->write( 'Failed: ' . $e->getMessage() );
20 $this->tests_failed++
;
23 public function addIncompleteTest( PHPUnit_Framework_Test
$test, Exception
$e, $time )
25 $this->logger
->write( 'Incomplete.' );
26 $this->tests_failed++
;
29 public function addSkippedTest( PHPUnit_Framework_Test
$test, Exception
$e, $time )
31 $this->logger
->write( 'Skipped.' );
32 $this->tests_failed++
;
35 public function startTest( PHPUnit_Framework_Test
$test ) {
37 'Testing ' . $test->getName() . ' ... ',
38 SeleniumTestSuite
::CONTINUE_LINE
42 public function endTest( PHPUnit_Framework_Test
$test, $time ) {
43 if ( !$test->hasFailed() ) {
44 $this->logger
->write( 'OK', SeleniumTestSuite
::RESULT_OK
);
49 public function startTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
50 $this->logger
->write( 'Testsuite ' . $suite->getName() . ' started.' );
52 $this->tests_failed
= 0;
55 public function endTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
56 $this->logger
->write('Testsuite ' . $suite->getName() . ' ended.' );
57 if ( $this->tests_ok
> 0 ||
$this->tests_failed
> 0 ) {
58 $this->logger
->write( ' OK: ' . $this->tests_ok
. ' Failed: ' . $this->tests_failed
);
61 $this->tests_failed
= 0;
64 public function statusMessage( $message ) {
65 $this->logger
->write( $message );