Skip to content

Coverage

Parity has two coverage workflows:

  • parity check reads coverage output generated by your existing tools.
  • parity test runs each belonging test individually and normalizes its single-test artifact when the original report cannot identify which test covered each line.

Preferred Format

Use formats with per-line and per-test attribution whenever available. parity-coverage.json is language-neutral. For PHP, PHPUnit XML directories generated with --coverage-xml provide the detail needed for matched coverage and attribution checks.

json
{
  "version": 1,
  "globalPercent": 80,
  "files": [
    {
      "path": "src/Foo.ts",
      "coveragePercent": 70,
      "totalExecutableLines": 10,
      "lines": [
        {
          "line": 1,
          "coveredBy": ["FooTest::coversPrimaryBehavior"]
        }
      ]
    }
  ]
}

Multiple Coverage Files

coverage_xml can be a single path or an ordered list. Parity uses the first existing path, which lets a project prefer detailed attribution locally and fall back to portable coverage in CI.

yaml
coverage_xml: [.parity/per-test, parity-coverage.json, coverage-xml, clover.xml, cobertura.xml]

Recommended order:

FormatUse whenSupports matched coverage
Parity JSONA converter or runner plugin can provide test names per lineYes
PHPUnit XML directoryPHPUnit or Pest can generate --coverage-xmlYes
Clover XMLPHP, Jest, Mocha/NYC, Vitest, or other tools emit CloverNo
Cobertura XMLRust, Python, Go, JVM, JS/TS, or CI tools emit CoberturaNo

Portable Format

Clover XML and Cobertura XML work across many ecosystems and support per-file coverage thresholds. They do not include enough detail to prove which test covered which line.

See Parity Coverage JSON for the full language-neutral attribution schema and converter example.

Generate Attribution With parity test

Configure the command used to run one expected test and the artifact it produces:

yaml
test:
  command: "./vendor/bin/pest {test_abs} --coverage-clover={coverage}"
  coverage: ".parity/tmp/{slug}.xml"
  reports: ".parity/per-test"
  timeout: 300

coverage_xml: [.parity/per-test, parity-coverage.json, coverage-xml, clover.xml, cobertura.xml]

parity test discovers the belonging tests from the same structures and file maps used by parity check. It runs them one at a time, writes .parity/per-test/index.json plus one normalized JSON report per test, and checks those reports automatically. Because each aggregate artifact came from only one test, Parity can safely attribute its covered lines to that test.

Generation happens in a staging directory. A failed, timed-out, or coverage-empty run leaves the previous complete report set untouched.