Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should code coverage be used as a "Milestone" that can block a project's progression?

Tags:

unit-testing

I am a development manager on a project with a painfully low unit test code coverage and we are definately feeling the weight of the "techincal debt" in the legacy code in our system.

My question is if anyone uses code coverage as a milestone or development threshold that prevents the project from moving to the next sprint until the code coverage reaches a specific level? What is the "best practice" for using the code coverage metric?

like image 790
Mark Ewer Avatar asked Dec 16 '09 14:12

Mark Ewer


People also ask

How do you use code coverage?

How is it measured? To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.

What is code coverage in Azure Devops?

Code coverage helps you determine the proportion of your project's code that is actually being tested by tests such as unit tests. To increase your confidence of the code changes, and guard effectively against bugs, your tests should exercise - or cover - a large proportion of your code.

What is milestone in git?

You can use milestones to track progress on groups of issues or pull requests in a repository.

What is code coverage build?

Code coverage is a metric that can help you understand how much of your source is tested. It's a very useful metric that can help you assess the quality of your test suite, and we will see here how you can get started with your projects.


1 Answers

Code coverage is a very relative thing. First of all because code coverage alone tells you nothing about the quality of your code or your unit tests. Secondly, sometimes it's easy to get 90% coverage with only a few tests, but sometimes it's very hard to even get to 50%. This is especially true with legacy projects which very often aren't designed to aid unit testing (to avoid external dependencies for example).

If you really want to use it as a milestone my advice is to take some important classes of your code, for example those who hold a lot of business logic, and see whether it's easy to achieve a high code coverage % on it. If this is the case, be sure the code coverage of such classes always stays up to par.

My experience tells me it takes up a lot of time to get high code coverage on legacy classes, and this isn't always worth the investment.

I hope this helps!

like image 94
Gerrie Schenck Avatar answered Nov 16 '22 00:11

Gerrie Schenck