PHPUnit2 3.0.0alpha11 released
posted: June 14th, 2006 · by: Sven
Wow :) Sebastian Bergmann finally added Mocks to PHPUnit2 which has been released as 3.0.0alpha11 to PEAR. The changelog reads quite interesting and comprehensive.
RSpec 0.5.5 on Rails released
posted: June 7th, 2006 · by: Sven
Hey, cool. I’ve just found an email dropping in my inbox that announces the release of RSpec 0.5.5. on Rails.
When I checked the last time, there’s been a short note on the “Tools: RSpec on Rails” page on RSpec’s project page saying something like “Yes, there’s an experimental extension in SVN and if you feel really adventurous you may check it out.” or so.
So I did, of course :) But unfortunately I haven’t got anywhere with it - the specs just haven’t been executed and from a quick look into the code I haven’t been able to tackle anything.
There’s been some discussion on the RSpec dev mailinglist since talking about the best way to integrate Rails support (i.e. as a plugin, gem, …) recently and I’m totally excited to read that there’s a release within less than a week now.
In the meantime there’s also an intro on the RSpec on Rails page linked above covering the installation process, howto run specs, naming conventions and each one example for usage with Rails models and controllers.
Honestly. I can’t wait to check this stuff out.
Howto get PHPUnit2 talk to a browser
posted: January 22nd, 2006 · by: Sven
Ok, I admit it took me a while to figure out how to run a PHPUnit2 testcase via http rather than cli on a Windows box.
First thing I needed to understand is that PHPUnit2_Util_Printer::__construct() sets fopen(‘php://stdout’, ‘r’); as output stream by default. This won’t output anything, so one has to advise the printer to use php://output.
Next thing was that I started the TestRunner by run(). Wrong way … this instantiated a new PHPUnit2_TextUI_TestRunner object and my output stream was send to nirvana.
The following works though:
$suite = new PHPUnit2_Framework_TestSuite();
$suite->addTestSuite(new ReflectionClass('MyTestCase'));
$runner = new PHPUnit2_TextUI_TestRunner();
$printer = new PHPUnit2_TextUI_ResultPrinter('php://output');
$runner->setPrinter($printer);
echo '<pre>';
$result = $runner->doRun($suite);
And don’t tell me to rtfm. I’ve found no docs on this. Nothing. I don’t think there are any. :(