Favoring Integration Tests Over Unit Tests to Verify Correctness
It only takes a little extra to inspire confidence in your system.
I’ve been writing unit tests since I started coding professionally. There’s a certain “zen” to it. It forces you to think about what it’s like to be another developer that has to use your code.
Even if that “other developer” is your future self.
Whenever I write a unit test, I not only want to verify correctness, but I also try to assess the class’ ergonomics–the developer experience that the class provides. I think an increasingly important aspect of writing good code is to write code that is pleasant to work with.
However, verifying overall system correctness is a trait that unit tests don’t possess.
Writing unit tests is dirt cheap. They’re impressively fast to write, execute, and verify a desired outcome. However, they’re also cheap in another sense. Unit tests are rarely enough to catch actual bugs that are likely to happen in production.
🔔 Want more articles like this? Sign up here.
Seeing something work in isolation under very controlled conditions is entirely different from seeing it work in a bigger setup, with multiple collaborating objects, different use cases…