Given the choice between working in a tested or untested codebase, most developers will choose the tested code in a heartbeat. Tests add reliability a

How to Incorporate Code Coverage for a Legacy Application

submited by
Style Pass
2021-05-25 02:30:06

Given the choice between working in a tested or untested codebase, most developers will choose the tested code in a heartbeat. Tests add reliability and stability to your application and allow developers to grow and change code with less fear of triggering unintended results.

Of course, legacy codebases are often missing tests, or have scant coverage. It can be daunting to even think about adding tests to them. Where do you start, what do you prioritize, and how to find time for it? Those are all vital questions for testing any application, but they’re even more important when you want to add tests to an existing, mature codebase with limited coverage.

The first step toward testing your legacy application is to find out what’s already being tested. Answering these questions can get you started:

Legacy applications often pass through many developers with many styles—you can find obsessively tested units passing their output to entirely untested functions. Mapping existing code coverage is the first step to systematizing and expanding a testing regimen. Remember, code coverage is the percentage of code that gets run by tests. Tools like Codecov can provide precise metrics tracking complicated coverage scenarios, like if statements, and integrate with deployment services like GitHub to indicate what code is covered.

Leave a Comment