DEV Community

Test Doubles - Fakes, Mocks and Stubs.

Michal Lipski on May 08, 2017

This text was originally posted at Pragmatists blog In automated testing it is common to use objects that look and behave like their production eq...
Collapse
 
ben profile image
Ben Halpern

I love the graphics. Really well-explained, Michal.

Collapse
 
mrcosta profile image
Mateus Costa

Perfect. Very clean explanation.
I would just add that regarding this part of the code:

when(gradebook.gradesFor(student)).thenReturn(grades(8, 6, 10));

The first part:

when(gradebook.gradesFor(student)) is also a mock. Because if the method gradesFor is called with another parameter, will never return what we expected.

You are not explicit doing a mock as when using "verify", but is still mock.

Collapse
 
mrlarson2007 profile image
Michael Larson

Love this article! Nice way of defining theses concepts.

Collapse
 
alisneaky profile image
Ali Sadreddini

Definitely an easy to follow article to refer to when people are talking about the topic and misusing the terms. And the graphics are awesome

Collapse
 
pierreroth64 profile image
Peio Roth

Short and clear. Thanks.

Collapse
 
thdaraujo profile image
Thiago Araujo

Nice article. Where did you create the diagrams? They're cool.