Optimizing Coverage in Unit Tests
Get familiar with how to optimize code coverage in your automated tests.
We'll cover the following...
When we use code coverage, we must ensure that our coverage is as close to 100% as possible, because that’s a good indicator that most of our executable code is covered by automated tests. However, being cautious is important. The goal is not only to chase coverage but to ensure that this coverage is also meaningful. Using high-quality tests that provide partial coverage and testing the remaining code manually is more helpful than 100% coverage without meaningful validations.
Even TDD does not guarantee 100% coverage. Even with writing the tests first, we must still do the following:
Mock the services that connect to external endpoints.
Exclude the adapter layer (REST API controller methods) from the unit tests.
Exclude application ...