Secret ingredients to quality software

Do you look for Code Coverage?

Last updated by Tiago Ara├║jo [SSW] on 23 Apr 2021 12:44 am (7 months ago) See History

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 for your project?

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?

Adam CoganAdam Cogan
Damian BradyDamian Brady
Eric PhanEric Phan
Matt WicksMatt Wicks

We open source. Powered by GitHub