[go: up one dir, main page]

Add test coverage reporting and CI integration

Overview

Currently there's no visibility into test coverage percentage or which code paths are tested.

Goals

  1. Generate test coverage reports
  2. Track coverage over time
  3. Enforce minimum coverage thresholds
  4. Display coverage in CI/CD pipeline

Implementation Tasks

1. Add Coverage Tool

Choose and integrate a Lua coverage tool:

  • Option A: luacov (most popular)

    • Install luacov
    • Configure .luacov file
    • Generate coverage reports
  • Option B: luacov-coveralls

    • For GitLab CI integration
    • Upload coverage to external service

2. Update Test Runner

Modify run-ci-locally.sh:

  • Enable coverage collection
  • Generate coverage report after tests
  • Display coverage summary
  • Save coverage data

3. GitLab CI Integration

Update .gitlab-ci.yml:

  • Add coverage job
  • Parse coverage output
  • Report coverage percentage
  • Fail if coverage drops below threshold
  • Generate coverage badge

4. Coverage Reporting

  • Generate HTML coverage reports
  • Highlight uncovered lines
  • Show coverage by file
  • Track coverage trends

5. Coverage Thresholds

Set minimum coverage targets:

  • Overall: 80% (aspirational)
  • Per module: 70% minimum
  • Critical modules (utils, template, remove): 90%

6. Documentation

Update docs with:

  • How to run coverage locally
  • How to interpret coverage reports
  • Coverage goals and current status
  • How to add tests to improve coverage

Files to Update

  • run-ci-locally.sh - Add coverage options
  • .gitlab-ci.yml - Add coverage job
  • .luacov - Coverage configuration
  • README.md - Add coverage badge
  • docs/ - Add testing documentation

Example Configuration

-- .luacov
return {
  statsfile = "luacov.stats.out",
  reportfile = "luacov.report.out",
  include = {
    "^lua/zk%-extras"
  },
  exclude = {
    "tests/",
  },
}

Coverage Goals (Progressive)

  1. Phase 1 (Current): 15% (only init tests)
  2. Phase 2: 40% (add utils, template tests)
  3. Phase 3: 60% (add command tests)
  4. Phase 4: 80% (comprehensive coverage)

Priority

Medium - Infrastructure improvement that enables better testing

Dependencies

Notes

  • Start with basic coverage reporting
  • Improve incrementally as tests are added
  • Don't block development on coverage requirements initially
  • Use coverage to identify gaps