Skip to content

Uploading coverage in advanced scenarios#

The following sections include instructions on how to use the Codacy Coverage Reporter to upload coverage data in more advanced scenarios.

Uploading multiple coverage reports for the same language#

If your test suite is split into different modules or runs in parallel, you must upload multiple coverage reports for the same language either at once or in sequence.

Alternatively, consider merging multiple coverage reports before uploading them to Codacy. Most coverage tools support merging or aggregating coverage data. For example, use the merge mojo for JaCoCo.

Note

If one or more coverage reports mark a line as covered multiple times, Codacy counts it as a single covered line when calculating coverage.

Uploading all reports at once#

Upload multiple partial coverage reports with a single command by specifying each report with the flag -r. For example:

bash <(curl -Ls https://coverage.codacy.com/get.sh) report \
    -l Java -r report1.xml -r report2.xml -r report3.xml

You can also upload all your reports dynamically using the command find. For example:

Note

This example works only on systems that use GNU find with support for the -printf action, such as Linux.

bash <(curl -Ls https://coverage.codacy.com/get.sh) report \
    -l Java $(find . -name 'jacoco*.xml' -printf '-r %p ')

Uploading reports in sequence#

Upload multiple partial coverage reports in sequence:

  1. Upload each report separately with the flag --partial.

    If you're sending reports for a language with the flag --partial, you must use the flag in all reports for that language to ensure the correct calculation of the coverage.

  2. Notify Codacy with the final command after uploading all reports.

For example:

bash <(curl -Ls https://coverage.codacy.com/get.sh) report \
    --partial -l Java -r report1.xml
bash <(curl -Ls https://coverage.codacy.com/get.sh) report \
    --partial -l Java -r report2.xml
bash <(curl -Ls https://coverage.codacy.com/get.sh) final

Uploading the same coverage report for multiple languages#

If your test suite generates a single coverage report for more than one language, you must upload the same coverage report for each language.

To do this, upload the same report multiple times, specifying each different language with the flag -l. For example:

bash <(curl -Ls https://coverage.codacy.com/get.sh) report \
    --partial -l Javascript -r report.xml
bash <(curl -Ls https://coverage.codacy.com/get.sh) report \
    --partial -l TypeScript -r report.xml
bash <(curl -Ls https://coverage.codacy.com/get.sh) final

Uploading coverage for Golang#

Codacy can't automatically detect Golang coverage report files because they don't have specific file names.

If you're uploading a Golang coverage report, you must also specify the report type:

bash <(curl -Ls https://coverage.codacy.com/get.sh) report \
    --force-coverage-parser go -r <coverage report file name>

Uploading coverage for unsupported languages#

If your language isn't in the list of supported languages, you can still send coverage to Codacy.

To do this, provide the correct language with the flag -l, together with --force-language. For example:

bash <(curl -Ls https://coverage.codacy.com/get.sh) report \
  -l Kotlin --force-language -r <coverage report file name>

See the list of languages that you can specify using the flag -l.

Share your feedback 📢

Did this page help you?

Thanks for the feedback! Is there anything else you'd like to tell us about this page?

We're sorry to hear that. Please let us know what we can improve:

Alternatively, you can create a more detailed issue on our GitHub repository.

Thanks for helping improve the Codacy documentation.

Edit this page on GitHub if you notice something wrong or missing.

If you have a question or need help please contact support@codacy.com.

Last modified December 18, 2023