Skip to content
Docs ·Test gaps and coverage

Configure

Test gaps and coverage

See which changed lines your tests run and which changed functions have no test, and have MergeHarbor write the missing tests.

Every pull request gets a Tests panel and a line in the review summary: how much of the changed code your tests run, and which changed functions with real logic have no test at all. MergeHarbor comments on those functions (three per review at most) and can write the missing tests for you.

Where the numbers come from

  • Coverage from CI (exact). Upload the report your test runner already writes: LCOV, Cobertura XML, a Go coverprofile or JaCoCo XML. MergeHarbor shows the share of changed lines that ran, file by file, and which lines did not.
  • An estimate (no setup). Without a report, MergeHarbor looks for tests the pull request changes, the usual test file for each changed file, and test files in your repository that call the function.

Small functions, trivial edits, tests, migrations, generated and vendored code are never reported. If no tests exist near the code at all, no comments are posted.

Upload coverage

  1. Go to Settings → Checks & gates → Test coverage and create an upload token. It can only upload coverage. Save it as the CI secret MERGEHARBOR_COVERAGE_TOKEN.
  2. Add the upload step after your tests. For GitHub Actions:
- name: Upload coverage to MergeHarbor
  if: always()
  env:
    MERGEHARBOR_COVERAGE_TOKEN: ${{ secrets.MERGEHARBOR_COVERAGE_TOKEN }}
    COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
  run: |
    gzip -c coverage/lcov.info | curl -sSf -X POST \
      -H "Authorization: Bearer $MERGEHARBOR_COVERAGE_TOKEN" \
      --data-binary @- \
      "https://app.mergeharbor.com/api/v1/coverage/upload?repo=$GITHUB_REPOSITORY&commit=$COMMIT"

The settings page has the same step for GitLab CI and any other CI, with your upload address filled in. Upload for the pull request’s head commit. Several uploads for one commit, such as test shards, are combined. A report that arrives after the review updates the pull request page.

Write tests

Select Write tests on the Tests panel, for one function or all untested ones:

  • With proof runs on, MergeHarbor writes tests and runs them in a sandbox. Tests that pass can be added to your pull request.
  • Otherwise MergeHarbor drafts test files, clearly marked as not run. Read them, then open them as a pull request in one click.

Settings

Under Settings → Review behaviour → Test gaps, or in .mergeharbor.yml:

review:
  test_gaps:
    enabled: true
    severity: minor
    min_function_lines: 6
    max_findings: 3
    coverage_target: 80

coverage_target is the share of changed lines your tests should run; pull requests below it say so.