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) × 100Example:
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:
Go to your pipeline execution
Select the Coverage tab
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

File-level coverage view
The file breakdown shows:
File path
Coverage percentage
Lines covered / total lines
Coverage change compared to base branch

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:

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 trends

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:
Separate pipelines: Run Test Intelligence in PR pipelines, run full coverage on nightly builds
Disable Test Intelligence for coverage: Turn off TI when measuring coverage
Use patch coverage only: Rely on patch coverage for PRs, total coverage for scheduled builds
Example: Separate pipelines
Troubleshooting
Next steps
Go to Onboarding Guide to set up code coverage
Go to Advanced Settings to configure exclusions and rollout strategies
Go to Upload test results to combine test results with coverage
Last updated
Was this helpful?