codespeak coverage

Improve test coverage in an existing project.

Synopsis

codespeak coverage [spec_path] --target N --max-iterations M [--no-interactive]

Description

Runs the test suite, measures code coverage, identifies uncovered code, and iteratively adds tests to bring coverage to the target level.

The iterative loop:

  1. Run tests with coverage measurement
  2. Identify uncovered lines and branches
  3. Generate new tests targeting uncovered code
  4. Repeat until target is reached or max iterations exhausted

Pre-existing test failures are ignored during improvement โ€” CodeSpeak only focuses on adding coverage, not fixing existing broken tests.

Flags

FlagDescription
spec_pathPath to the specification file. If omitted, all registered specs are processed
--target NTarget coverage percentage (1-100). **Required**
--max-iterations MMaximum number of coverage improvement iterations (1-30). **Required**
--no-interactiveRun in non-interactive mode without real-time progress updates

Language support

codespeak coverage is language-agnostic. When you run codespeak test --auto-configure, it detects your language and test framework and writes the necessary commands to run tests with coverage in LCOV format. This works across Python, JavaScript, Go, and other languages.

Test runner configuration

CodeSpeak needs to know how to run tests with coverage reporting. This is stored in codespeak.json under test_runner_configurations. You can either:

  1. Auto-configure with codespeak test --auto-configure (recommended)
  2. Manually configure the test runner commands in codespeak.json

The configuration must include a run_all_tests_with_coverage_command containing both {tests_report_file} (JUnit XML results) and {tests_coverage_report_file} (LCOV coverage data) macros.

Error messages

ErrorCauseResolution
Can't find spec to buildNo .cs.md files found and no specs registered in codespeak.jsonCreate a spec file or register one in codespeak.json
Cannot specify both a positional spec path and --specBoth positional path and --spec flag providedUse one or the other
Anthropic API Key not foundNo API key configuredSet the ANTHROPIC_API_KEY environment variable or run through the interactive setup
Circular spec dependency detected: A -> B -> ASpec imports form a cycleRemove the circular import
{path} does not belong to a CodeSpeak projectNo codespeak.json foundRun codespeak init first
--max-iterations must be between 1 and 30Invalid iteration countUse a value between 1 and 30
--target is requiredMissing --target flagSpecify a target: --target 100
--max-iterations is requiredMissing --max-iterations flagSpecify iterations: --max-iterations 5
--target must be between 1 and 100Target out of rangeUse a value between 1 and 100
'{field}' is missing in codespeak.jsonTest runner not configuredRun codespeak test --auto-configure or configure manually
'{field}' in codespeak.json is still a placeholderAuto-configured field was not filled inEdit the placeholder value in codespeak.json
Coverage command must include {tests_coverage_report_file} placeholderCoverage command missing LCOV output macroAdd the macro to the command string
No testable source files foundNo managed files with source code for this specEnsure the spec has managed files
Reached target coverage but N new test failures remainTests were added but some failFix the failing tests manually or increase --max-iterations
Failed to reach target coverage after N iterationsCoverage target not achievable in the given iterationsIncrease --max-iterations or lower --target

See also