Skip to content

Increase test coverage from 79% to 95% #2

@genro

Description

@genro

Current Status

Test coverage has been significantly improved from 55% to 79% (+24 points).

Modules at 90%+ Coverage ✅

  • config.py: 100%
  • processor.py: 100%
  • metadata.py: 96%
  • server.py: 91%
  • include.py: 90%

Remaining Work

cli.py: 55% coverage ⚠️

The main blocker is ~100 lines of interactive CLI code using input() which are difficult to test:

  • Lines 189-236: Interactive refresh mode
  • Lines 307-358: Interactive apikey management
  • Lines 415-520: Interactive serve command setup

These sections prompt the user for input and are hard to test without complex mocking or integration tests.

Possible Approaches

  1. Refactor interactive sections to separate I/O from logic (recommended)

    • Extract input/output to dedicated functions
    • Test business logic separately
  2. Mock input() and print() in tests

    • Complex to maintain
    • Fragile tests
  3. Add integration tests with simulated input

    • More realistic but slower
    • Requires test infrastructure
  4. Accept current coverage as sufficient

    • Core logic well tested (90%+ on 5/6 modules)
    • Interactive sections are simple and unlikely to break

Recommendation

Refactor interactive sections when modifying CLI, gradually improving coverage. Current 79% coverage is acceptable for core functionality.

Related

  • Total test count: 125 passed, 5 skipped
  • New test files added: test_include_ai.py, test_include_errors.py, test_include_ai_errors.py, test_server.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions