For the complete documentation index, see llms.txt. This page is also available as Markdown.

Understanding Results

Explain calculations and walk through UI elements

Learn how code coverage is calculated and how to interpret the results in Harness.

What you will learn from this topic

  • How total coverage and patch coverage are calculated

  • Where to view coverage results in the Harness UI

  • How to interpret coverage metrics and trends

  • How to read quality gate output when a threshold fails

Before you begin

  • Your pipeline has run at least once with a coverage upload step. Go to Onboarding Guide to set up coverage if you have not done so.

How coverage is calculated

Harness calculates coverage based on the coverage reports you upload.

Total coverage

Total coverage represents the percentage of all lines in your codebase that are executed during testing:

Total Coverage = (Covered Lines / Total Lines) × 100

Example:

  • Total lines: 1,000

  • Covered lines: 750

  • Total coverage: 75%

Patch coverage

Patch coverage measures the percentage of changed lines that are covered by tests. This metric only appears for pull request builds.

Example (PR with 20 changed lines):

  • Changed lines: 20

  • Covered changed lines: 18

  • Patch coverage: 90%

Patch coverage helps ensure new code is properly tested before merging.

Where to view coverage results

Coverage tab (execution view)

After a pipeline execution completes, view coverage in the Coverage tab:

  1. Go to your pipeline execution

  2. Select the Coverage tab

  3. View coverage metrics:

    • Total Coverage: Overall codebase coverage percentage

    • Patch Coverage: Coverage for changed lines (PRs only)

    • Coverage Trend: Historical coverage over time

    • Per-File Breakdown: Coverage percentage for each source file

Coverage tab showing patch coverage for a pull request

File-level coverage view

The file breakdown shows:

  • File path

  • Coverage percentage

  • Lines covered / total lines

  • Coverage change compared to base branch

File-level coverage view

Line-by-line coverage (diff view)

For pull requests, the diff view shows line-by-line coverage with color coding:

  • Green: Line is covered by tests

  • Red: Line is not covered by tests

  • Yellow: Line is partially covered (some branches covered, others not)

This helps you quickly identify untested code in your changes.

Pull request comments

When configured, Harness posts coverage results as PR comments:

PR comment showing coverage report

Go to Onboarding Guide to configure PR comments.

Understanding coverage metrics

Good coverage vs. complete coverage

  • High coverage (80%+): Indicates most code paths are tested

  • 100% coverage: Does not guarantee bug-free code - focus on meaningful tests

Aim for meaningful coverage of critical paths rather than perfect coverage of all code.

When patch coverage matters most

Patch coverage is crucial for:

  • Pull request reviews

  • Ensuring new features are tested

  • Preventing coverage regression

Set higher thresholds for patch coverage (e.g., 80%) than total coverage (e.g., 70%) to ensure new code maintains quality standards.

Coverage trend chart

The coverage trend chart shows how coverage changes over time:

  • Upward trend: Test coverage is improving

  • Downward trend: Coverage is declining - consider adding tests

  • Stable: Coverage is consistent

Use trends to track progress toward coverage goals.

Quality gate results

When a quality gate fails, the pipeline stops with a clear error message:

This indicates:

  • Which threshold failed

  • Current vs. required coverage

  • How many lines need additional tests

Code coverage and Test Intelligence

Test Intelligence and Code Coverage have conflicting objectives:

  • Test Intelligence: Runs fewer tests to speed up pipelines

  • Code Coverage: Requires running all tests for accurate metrics

For Java and Python, you can run both together. Harness records coverage for each test as it runs and reuses stored coverage for the tests that were skipped, so coverage stays accurate without running the full suite. Go to Test Intelligence with Code Coverage to set this up.

For other languages, keep the two concerns separate:

  1. Separate pipelines: Run Test Intelligence in PR pipelines, run full coverage on nightly builds

  2. Disable Test Intelligence for coverage: Turn off TI when measuring coverage

  3. Use patch coverage only: Rely on patch coverage for PRs, total coverage for scheduled builds

Example: Separate pipelines

Troubleshooting

Coverage shows 0%

Possible causes:

  • Coverage file path is incorrect

  • Coverage file was not generated before upload

  • Wrong file format specified

Verify the coverage file path matches your tool's output location:

Patch coverage is not shown

Possible causes:

  • Not running on a pull request build

  • Base branch not configured

Ensure you are running on a PR and specify the base branch:

Coverage is incomplete or inaccurate

Possible causes:

  • Tests failed or exited early

  • Test timeouts

  • Crashes during test execution

Ensure all tests complete successfully before evaluating coverage. Check for:

  • Test failures with --exitfirst flag

  • Timeouts in long-running tests

  • Crashes or exceptions that terminate test runs early

Next steps

Last updated

Was this helpful?