Unit Testing is Overrated
Here are the main takeaways:
- Think critically and challenge best practices
- Don't rely on the the test pyramid
- Separate tests by functionality, rather than by classes, modules, or scope
- Aim for the highest level of integration while maintaining reasonable speed and cost
- Avoid sacrificing software design for testability
- Consider mocking only as a last resort
I have two notes:
- Relying on acual GeoIP provider - I'd fake it for PR gates because we don't want to block our PRs when the provider has an outage. I keep using it for CD gates.
- Caching test is not sufficient - I'd add assert the cache contains tested record.
The article links another good posts:
- Write tests. Not too many. Mostly integration. - The Testing Trophy
It doesn't matter if your component renders component b with props c and d if component b actually breaks if prop e is not supplied. So while having some unit tests to verify these pieces work in isolation isn't a bad thing, it doesn't do you any good if you don't also verify that they work together properly. And you'll find that by testing that they work together properly, you often don't need to bother testing them in isolation. - Testing of Microservices - integration test is the king
No comments:
Post a Comment