Codecov

Code coverage done right.®

Welcome to Codecov Documentation. You'll find comprehensive guides and documentation to help you start working with Codecov as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Flags

Group coverage reports based on type of tests or system.

Flags allow you to isolate coverage reports for different tests. This is particularly helpful if you have multiple types of tests (e.g., unit, integration, frontend, backend, etc), or you're employing a monorepo setup where you'd like to encapsulate each project's test coverage independently.

Flag Creation

For coverage information to be properly tracked per flag, the flags must be applied at upload time.

To apply a flag simply submit coverage reports with the -F flagname included in the upload command; Codecov will do the rest.

The following example illustrates how you may run specific test groups and upload coverage, flagging each coverage group. This strategy for uploading is preferred as it cleanly associates a single flag with a single report.

# example running unittests only
py.test --cov=./ -k tests/unittests/
bash <(curl -s https://codecov.io/bash) -c -F unittests

# example running integration tests only
py.test --cov=./ -k tests/integration/
bash <(curl -s https://codecov.io/bash) -c -F integration

# example running ui tests only
npm test
bash <(curl -s https://codecov.io/bash) -c -F ui

Remove old reports after uploading (optional)

Apply the -c argument to clear the workspace of all coverage reports before running you next set of tests.

Flags must be lowercase, alphanumeric, and not exceed 45 characters

Only lowercase, alphanumeric values are accepted. ^[a-z0-9_]{1,45}$

Flag Usage

Toggle flags in the source code overlay

Once properly configured, you can toggle flags in the source code overlay to see how tests using different flags interact with your source code and impact coverage.

**Source code overlay** Toggle `unittests`, `integration` and `ui` coverage reports with one tap.

Source code overlay Toggle unittests, integration and ui coverage reports with one tap.

Filter flags in tree navigation (coming soon)

**Navigate** with specific flags visible.

Navigate with specific flags visible.

Flag badges and graphs

Badges and graphs may express specific flags only. More details on this will come soon.

Create custom notifications

Flags can be used to create custom notifications to your repository provider. This makes it easy to see per-flag converage information alongside pull requests.

You can specify Flags in your Codecov Yaml for statuses and all notifications.

coverage:
  status:
    project:
      default: off
      frontend:
        flags: frontend
      backend:
        target: 50%
        flags: backend
      api:
        target: 89%
        flags: api

flags:
  # filter the folder(s) you wish to measure by that flag
  backend:
    # only include files in the backend folder
    paths:
      - app/backend/
  frontend:
    paths:
      - app/frontend/
  api:
    paths:
      - app/api/
  tests:
    paths:
      - tests/
**Custom Statuses** only report on specific Flags.

Custom Statuses only report on specific Flags.

Hide Builds (e.g., nightly builds)

Codecov provides a strategy to isolate specific builds from the master report while maintaining the report's integrity. When reports are not joined into the master report, they will be ignored for comparison, although they will remain accessible for source overlay, api, badges, and graphing.

A nightly build is an excellent example of this feature. What follows is a yaml configuration for a nightly build.

flags:
  nightly:
    joined: false

Now that we have configured the flag nightly to not join into the master report, let's upload a report flagged as nightly.

bash <(curl -s https://codecov.io/bash) -F nightly

By adding -F nightly we mark all the coverage report data for this build as nightly coverage data.