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?
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.
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.
You can use milestones to track progress on groups of issues or pull requests in a repository.
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.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With