News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Raphael Stolt's Blog:
Creating custom PHPUnit assertions
July 29, 2008 @ 10:25:15

Raphael Stolt has written up a post for his blog talking about custom PHPUnit assertions and a simple method to create them.

In this blog post I'd like to set the focus on some of the aspects of the Custom Assertion pattern, by showing how to create custom PHPUnit assertions, which attacks the above mentioned smell [of bad test code] and its retroactive effects with a huge antiperspirant flagon, while also providing the chance to build a customer friendly and domain related test vocabulary.

His first assertion is simple, checking the contents of a bag object to be sure that there are no duplicate items and that its content count is reduced by one if something is removed. Then, he moves on to making the custom assertion for his "IdShouldFollowAgreedConvention" test. He explains how to use the assertion class and how it all fits together in the final, functional test case.

0 comments voice your opinion now!
custom phpunit assertion unittest customassertion pattern


blog comments powered by Disqus

Similar Posts

Brandon Savage's Blog: Peer Review: Testable Code And Architecture

PHPBuilder.com: PHPUnit Fundamentals: Setting Up and Tearing Down a Doctrine 2 Database

PHP Town Hall Podcast: Episode #3 - The EE Revolt of 2012 and Why You Should Unit-test Your Shit

NetTuts.com: Refactoring Legacy Code: Part 2 - Magic Strings & Constants

Anna Filina's Blog: 10 Reasons to Write Unit Tests


Community Events





Don't see your event here?
Let us know!


bugfix project library release introduction code api threedevsandamaybe podcast wordpress language interview framework application configure developer community laravel series list

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework