DEV Community

Discussion on: Test Doubles - Fakes, Mocks and Stubs.

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.