Home » QuickTips

The Difference Between Mocks and Stubs

10 June 2009 461 views No Comment

Found this Fowler article pretty insightful when thinking about the difference between mocks and stubs. New to the mocking scene, I didn’t understand the difference at first, but the latter part of the portion I have linked to states that Mocks are used to validate behavior whilst Stubs are used to validate state . Looking at the two example tests, the difference between the two types of tests becomes readily apparent. One tests the certain methods fired, and the other tests that properties of an object contain the values that we thought they should be.

http://www.martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.