sebastianbergmann/phpunit — Issue #506: exception in test listeners should be catchable
Author: llaville
Created: 2012-02-21 11:39:14+00:00
State: open

I'm working on a compatible solution Windows - Mac Growl test status notifier (as originaly developed by Raphael Stolt : http://raphaelstolt.blogspot.com/2010/06/growling-phpunits-test-status.html).

During my tests, I found an issue when a custom test listener throws an exception. TestRunner did not catch it and we have to read the error log to see results.

Minimal implementation of my growl listener

Just checking that PEAR::Net_Growl package is available, otherwise throws an exception

With minimal phpunit XML configuration

.
./Reference

When running unit test suite with command

phpunit -c phpunit-growl-listener-demo.xml .

I got nothing on console output, but this report on error log

[21-Feb-2012 12:24:14] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'The Growl Listener requires the Net_Growl PEAR package.' in C:\tests\phpunit\GrowlTestListenerDemo.php:12
Stack trace:
#0 C:\UwAmp\bin\php\php-5.2.17\PEAR\PHPUnit\TextUI\TestRunner.php(617): GrowlTestListenerDemo->__construct()
#1 C:\UwAmp\bin\php\php-5.2.17\PEAR\PHPUnit\TextUI\TestRunner.php(140): PHPUnit_TextUI_TestRunner->handleConfiguration(Array)
#2 C:\UwAmp\bin\php\php-5.2.17\PEAR\PHPUnit\TextUI\Command.php(192): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#3 C:\UwAmp\bin\php\php-5.2.17\PEAR\PHPUnit\TextUI\Command.php(130): PHPUnit_TextUI_Command->run(Array, true)
#4 C:\UwAmp\bin\php\php-5.2.17\phpunit(46): PHPUnit_TextUI_Command::main()
#5 {main}
thrown in C:\tests\phpunit\GrowlTestListenerDemo.php on line 12