November 2024
Intermediate to advanced
300 pages
7h 12m
English
A good mock-based test is three lines: a one-line arrange step with a highly readable smart stub declaration, followed by one-line act and assert steps. That’s a test anyone can quickly read, understand, and trust.
In answersAppropriateAddressForValidCoordinates, the expected parameter string of "lat=38.000000&lon=-104.000000" correlates clearly with the act arguments of 38.0 and -104.0. Creating correlation between arrange and assert isn’t easy sometimes, but it saves developers from digging about for understanding. Without such correlation, tests using mocks can be hard to follow.
Mocks supplant real behavior. Ask yourself if you’re using them safely. Does your mock really emulate the way the production ...
Read now
Unlock full access