Tests - How Many Tests are Enough, and Why?
What tests would you need to feel comfortable deploying code to production without any manual testing? That's the answer to how many tests are enough.
Let's break that down. A textbook answer would be:
- lots of unit tests in the application
- fewer integration tests like postman tests
- even fewer end to end tests like cypress tests
However, I don't agree with that answer.
On the unit tests - they can be a by-product of test driven development. But once they exist, they may not be needed if integration tests are sufficient to test the inputs and outputs of the system. In fact, if large scale refactoring is done, then a disadvantage would be that unit tests would also need to be refactored. While integration tests would not need change with a large scale refactoring because they don't rely on the internal implementation. Inputs and outputs are
On integration tests - testing all business cases is what is relevant. Instead of all possible permutation to meet 100% code coverage.
On end to end tests - they are the final piece to avoid manual testing and are super useful.
So to answer how many tests are enough - again, it's enough to feel confident. And that may not need to include unit tests at all.