Coverage

For the next steps, we assume that you already have tests and coverage for your project. If you don't have coverage and need help, check our how to generate coverage.


Projects can be configured to show code coverage reports directly in Codacy. Codacy reads the source coverage reports, converts them to a smaller JSON file and uploads them, showing all results integrated into your project's dashboard.

Project API Token


To setup coverage report you'll need a project API token. You can find it in your project settings 'Integrations' tab.

Jun-06-2017_14-30-02.gif
 

 

Token Security

You should keep your API token well protected, as it grants owner permissions to your projects. If you use CircleCI or Travis CI, you should use your token as an environment variable. (Don't put your keys in your configuration files, check your service settings on how to set environment variables)

 

Setting token as environment variable

export CODACY_PROJECT_TOKEN=%Project_Token%

(replacing %Project_Token% with your token)

 

Setup


Check detailed instructions on how to setup coverage in each reporter plugin.

 

POST API


If your language or build tool isn't supported yet, you can send the coverage data directly through the API. You can check the endpoint in the API Docs and an example of the JSON payload below.

{
  "total": 23,
  "fileReports": [
    {
      "filename": "src/Codacy/Coverage/Parser/CloverParser.php",
      "total": 54,
      "coverage": {
        "3": 3,
        "7": 1
      }
    }
  ]
}

Note: In case the token was retrieved from the Project integrations tab, the header should be project_token. If it is an account token, the header should be api_token.

 
SEE ALSO
 

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.