News Feed
Sections




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

Lars Tesmer's Blog:
What My Co-Workers and I Learned When Trying to Write Unit Tests for PHPUnit
September 09, 2011 @ 11:56:04

Lars Tesmer and his coworkers have been working on improving their development skills lately, specifically related to unit testing. In his latest post he shares some of what they've discovered along the way.

The plan was to try and write as many tests as we could for the Constraint classes PHPUnit uses to implement its assertions. [...] Well, our plan didn't work out that way, we didn't really succeed in writing a considerable amount of unit tests. However, it still was a valuable experience, as it turned out the unit tests of the Constraints are a good example of how not to unit test.

He includes three of the major points they came across in their practice development:

  • Don't use one single test case class to test several different classes
  • Name your tests well
  • Avoid to test more than one behaviour in one single test

For each, there's a summary answering the "why" question behind them including an example test (testConstraintIsType) that shows a bad, multiple assertion practice that should be avoided if possible.

0 comments voice your opinion now!
unittest phpunit recommendations opinion bestpractice


blog comments powered by Disqus

Similar Posts

Joshua Thijssen's Blog: LAMP-stack? Forget it! Itís a LAMPGMVNMCSTRAH-stack now...

Sebastian Göttschkes' Blog: Testclasses for symfony2

PHPMaster.com: PHPMaster Security Roundup

Leszek Stachowski's Blog: php anachronic coding standards

Charles Sprayberry's Blog: Why you should use DI


Community Events

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


library version series community extension php7 introduction symfony2 api podcast example framework interview laravel performance conference opinion install release voicesoftheelephpant

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