Skip to main content
Skip to content

Viewing code coverage for your repository

Track whether code coverage on your default branch is improving or regressing over time.

谁可以使用此功能?

具有写入访问权限的用户

GitHub Team 或 GitHub Enterprise Cloud

注意

The repository coverage overview is in 公开预览 and subject to change.

Prerequisites

Viewing code coverage

The Code coverage overview shows a snapshot of your repository's coverage at a glance, highlighting the current line coverage and trends over time.

  1. 请导航到您的存储库中的** Security and quality** 选项卡。
  2. 单击以展开 代码质量,然后单击 常规发现。
  3. In the top right corner of the "Code coverage" score card, click View insights.
  4. To understand current coverage on your default branch, review the "Total line coverage" percentage:
    • The line coverage percentage represents the number of lines covered by tests divided by the total number of executable lines, expressed as a percentage. If you upload multiple reports, each line is counted once. See How total line coverage is calculated.
    • If a coverage goal is set, compare this percentage with the goal to see whether your coverage meets it.
  5. To see whether coverage is improving or declining over time, review the "Line coverage over time" line graph. Use the time period dropdown to select the last 14, 30, or 90 days.
  6. Optionally, to filter the results, use both the language and label filters to select the coverage you want to review. You must use both filters.
  7. To set a coverage goal, to the right of "Total line coverage", click and enter the desired percentage.

Next steps

To improve coverage in the files that need it most, use Copilot to write tests. See 测试代码.