Skip to main content
API coverage is a planned feature. The coverage analysis package exists but the --coverage, --openapi, and --coverage-output CLI flags are not yet wired into the hitspec run command. This page describes the intended behavior.
API coverage tracking will compare your test files against an OpenAPI specification to show which endpoints have tests and which do not. This helps identify gaps in your test suite.

Planned Usage

Once wired up, enable coverage with the --coverage flag and point to your OpenAPI spec:
hitspec run tests/ --coverage --openapi api-spec.yaml

Coverage Output

By default, coverage results are printed to the console. You can also generate HTML or JSON reports:
# HTML report
hitspec run tests/ --coverage --openapi api-spec.yaml --coverage-output coverage.html

# JSON report
hitspec run tests/ --coverage --openapi api-spec.yaml --coverage-output coverage.json

What Coverage Tracks

The coverage report shows:
  • Overall coverage percentage — the ratio of tested endpoints to total endpoints in the spec
  • Covered endpoints — endpoints that have at least one test request matching the method and path
  • Uncovered endpoints — endpoints defined in the spec with no matching test
  • Coverage by tag/category — grouped by OpenAPI tags if present

Flags

FlagDescription
--coverageEnable API coverage tracking
--openapiPath to the OpenAPI/Swagger specification file (YAML or JSON)
--coverage-outputOutput file path. File extension determines format (.html or .json)

Example

Given an OpenAPI spec with 20 endpoints and tests covering 15 of them:
$ hitspec run tests/ --coverage --openapi spec.yaml

Tests: 15 passed, 0 failed
Coverage: 15/20 endpoints (75%)

Uncovered:
  GET  /api/admin/settings
  PUT  /api/admin/settings
  POST /api/reports/generate
  GET  /api/reports/{id}/download
  DELETE /api/users/{id}/sessions

CI/CD Integration

Use coverage reporting in your CI pipeline to track coverage over time:
- name: Run API tests with coverage
  run: |
    hitspec run tests/ \
      --coverage \
      --openapi api-spec.yaml \
      --coverage-output coverage.html \
      --output junit \
      --output-file results.xml

- uses: actions/upload-artifact@v4
  with:
    name: api-coverage
    path: coverage.html
Run coverage checks locally before pushing to catch missing tests early. Pair coverage with the OpenAPI import command to generate test stubs for uncovered endpoints.