> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/code-quality/code-coverage.md).

# Code Coverage

Code Coverage shows how much of your code your tests actually exercise. Run your test suite in CI, upload the [LCOV](https://github.com/linux-test-project/lcov) report, and review coverage per repository, file, and line in Aikido.

{% hint style="info" %}
PR gating on coverage is coming soon. Today Aikido reports coverage in the dashboard. It does not fail pull requests when coverage drops.
{% endhint %}

## How it works

1. Your CI job runs tests with coverage enabled and writes one or more `lcov.info` files.
2. The [Aikido Code Coverage GitHub Action](https://github.com/AikidoSec/code-coverage-github-action) uploads the report to Aikido.
3. Aikido stores the report against the repository, commit SHA, and branch.
4. The **Code Coverage** tab shows the latest upload for each repository.

## Use cases

* **See which repositories are under-tested:** compare overall coverage across the repos connected to Aikido.
* **Find gaps in a codebase:** open a repository and browse uncovered files in the code tree or file list.
* **Inspect a file before you change it:** open line-level coverage against the source so you know what tests already cover.
* **Track whether coverage is improving:** use coverage over time as you add tests or clean up dead code.
* **Pair coverage with quality work:** when a [repository scan](/code-quality/repository-scans.md) or [PR check](/code-quality/code-quality-setup.md) flags a file, check whether that file is tested.

## Prerequisites

Before you start, make sure:

* You're on a **Basic**, **Pro**, **Advanced**, or **Enterprise** plan. Code Coverage isn't available on the Developer plan.
* The repository is [connected to Aikido](/code-scanning/connect-your-source-code.md).
* Your tests can emit an **LCOV** report (`lcov.info`). Jest and pytest-cov can write this natively. Other runners work if they can export LCOV.

{% hint style="info" %}
Code Coverage uploads are currently available for GitHub. Support for other SCMs, including Azure DevOps, GitLab, and Bitbucket, is coming soon.
{% endhint %}

## Set up the GitHub Action

Use the [Aikido Code Coverage GitHub Action](https://github.com/AikidoSec/code-coverage-github-action). It authenticates with GitHub OIDC, so no API token or repository secret is required.

After your tests write an LCOV file, add a step like this:

```yaml
- name: Upload coverage to Aikido
  uses: AikidoSec/code-coverage-github-action@v1
  with:
    lcov-file-paths: coverage/lcov.info
```

The job that runs the action must grant `id-token: write`.

For the full workflow, multiple reports, monorepos, and all inputs, follow the [GitHub Action README](https://github.com/AikidoSec/code-coverage-github-action).

## View coverage in Aikido

After the next successful upload:

1. Open [**Code Quality** > **Code Coverage**](https://app.aikido.dev/code-quality/code-coverage).
2. Search the repository list. Each row shows overall coverage and when it was last updated.
3. Open a repository to see:
   * **Coverage summary**: covered, partial, and uncovered line counts
   * **Coverage over time**: how the percentage changes across uploads
   * **Files**: browse as a **Code Tree** or a flat **File List**
4. Open a file to inspect line-level coverage against the source.

Source preview depends on Aikido having imported the file. If the source isn't available yet, coverage percentages still show in the file list.

<div data-with-frame="true"><figure><img src="/files/ce8qBllmHx292Vc4YQRX" alt=""><figcaption><p>Code Coverage shows repository-level trends and file-by-file coverage in one view.</p></figcaption></figure></div>

## Troubleshooting

* **Nothing appears in Aikido**: confirm the repository is connected to Aikido, the LCOV file contains at least one parseable source file, and the upload step ran.
* **Coverage looks incomplete**: if you shard tests or use a matrix, merge every `lcov.info` into one upload per commit. See the [GitHub Action README](https://github.com/AikidoSec/code-coverage-github-action#monorepo-with-matrix-jobs).
* **The report is rejected as too large**: Aikido accepts LCOV payloads up to 10 MB. Narrow the coverage output or exclude generated files before upload.
* **The action fails**: check the [GitHub Action README](https://github.com/AikidoSec/code-coverage-github-action) for required permissions and inputs.

## Need help?

Open the **Intercom chat** in the bottom right corner. Our team is here to help.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/code-quality/code-coverage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
