Do you look for Code Coverage?
30/07/2019 10:59 AM by
Code Coverage shows how much of your code is covered by tests and can be a useful tool for showing how effective your unit testing strategy is. However, it should be looked at with caution.
- You should focus on *quality* not *quantity* of tests.
- You should write tests for fragile code first and not waste time testing trivial methods
- Remember the 80-20 rule - a very high-test coverage is a noble goal but there are diminishing returns.
- If you're modifying code, write the test first, then change the code, then run the test to make sure it passes (AKA red-green-refactor).
- You should run your tests regularly (see Do you follow a Test Driven Process). Ideally, they'll be part of your build (see Do you know the minimum builds to create on any branch)
- Figure: Code Coverage metrics in Visual Studio. This solution has a very high code coverage percentage (around 80% on average)
Tip: Do you use Live Unit Testing to see code coverage?
Do you feel this rule needs an update?