# Set up test coverage
With the test coverage analyzer, you can setup your CI systems to send metrics to DeepSource. An issue will be raised when lines are not covered or reachable during tests.
Before proceeding, please ensure that you've created an account on DeepSource, and have added "Test Coverage" analyzer when enabling analysis (for the repository you want to set up test coverage for).
In case, Test Coverage analyzer was not added, add the following to your
[[analyzers]] name = "test-coverage" enabled = true
Here's what you need to do in order to setup test coverage:
- After running your tests, generate the test coverage report.
- For Python projects, this can be done using
coverage xml(or with
pytest-covfor pytest projects) - this would create an XML file
coverage.xmlwith all the information we need for tracking your test coverage.
- For Go projects, the
-coverprofileoption can be used to generate
go test -coverprofile=cover.out
- Install DeepSource CLI - To facilitate easy reporting of test coverage reports, DeepSource's CLI client is used. Use the following command to download it:
curl https://deepsource.io/cli | sh
- Find the repository's DSN and save it in an environment variable named
DEEPSOURCE_DSN. To find DSN for your repository, go to Dashboard > Select Repo > Repo Settings > Reporting > DSN.
A Data Source Name (DSN) is a unique identifier used by DeepSource's systems to identify the repository.
- Report Coverage - From the repository's root, execute the following command:
./bin/deepsource report --analyzer test-coverage --key $LANG --value-file $COVREPORT
$COVREPORT according to the following table:
|Project Language|| |