News Feed
Sections




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

Juan Treminio:
Unit Testing Tutorial Part V Mock Methods and Overriding Constructors
April 05, 2013 @ 09:38:49

Juan Treminio has posted the latest part of his unit testing series to his site today - the fifth part that looks at using mock methods on mock objects and overriding constructors.

Previously in my PHPUnit tutorial series, you learned about the very powerful concept of mock objects and stub methods. This concept is central to successful unit testing, and once it fully 'clicks' in your head you will start to realize how useful and simple testing can be. There is also another thing I want to make clear: creating tests is basically a puzzle - you simply have to go step by step, making sure all the pieces fit together correctly so you can get your green. I hope to make clear what I mean by the end of this tutorial.

He assumes you already know about mock objects and introduces the concept of "stub methods" and "mock methods", noting the difference between them. He then gets into what he calls the "four pathways of getMockBuilder" and talks about the rationale behind mocking methods in the first place. He then gets into constructors and how you can work around the "bad" ones with help from mock object functionality.

If you're interested in reading the rest of the series, you can find links to them here.

0 comments voice your opinion now!
phpunit tutorial mock method object constructor

Link: http://jtreminio.com/2013/03/unit-testing-tutorial-part-5-mock-methods-and-overriding-constructors/

blog comments powered by Disqus

Similar Posts

NETTUTS.com: Build an RSS 2.0 Feed with CodeIgniter

Happy Accidents: Orno Skinny Series Part 1: Building a RESTful API

Matthew Weier O'Phinney's Blog: ZF2 Forms in Beta5

Padraic Brady's Blog: The Mockery: An Independent Mock Object and Stub Framework for PHP5

Chris Hartjes' Blog: Building a Gimmebar Sidebar


Community Events

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


language podcast yii2 api php7 programming framework laravel series community opinion example composer list application interview symfony part2 introduction project

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