Improving Test Abstraction When Using Test Doubles
It’s easy to craft tests that are difficult for others to read. When using test doubles, it’s even easier to craft tests that obscure information critical to their understanding.
ReturnsDescriptionForValidLocation is difficult to understand because it hides relevant information, violating the concept of test abstraction (see Test Abstraction).
c5/4/PlaceDescriptionServiceTest.cpp | |
| TEST_F(APlaceDescriptionService, ReturnsDescriptionForValidLocation) { |
| HttpStub httpStub; |
| PlaceDescriptionService service{&httpStub}; |
| |
| auto description = service.summaryDescription(ValidLatitude, ValidLongitude); |
| |
| ASSERT_THAT(description, Eq("Drury Ln, Fountain, CO, US")); |
| } |
Why do we expect the description ...
Get Modern C++ Programming with Test-Driven Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.