Current status and next steps for test coverage improvement.
Coverage: ~38-39% (from 27% initially) Target: 70% (per #425)
Infrastructure Fixes:
- Fixed Debian coverage workflow (critical CI fix)
- Established cache management strategy
- Fixed opam initialization issues
Test PRs:
- Phase 2: Basic TUI tests for all install forms (node, baker, accuser, DAL)
- Phase 3: Modal helpers + instances page tests
- Validation: Added validation/error tests to all forms
- Mock System capability for file browser testing
test/
├── test_install_node_form.ml (493 lines) ✅
├── test_install_baker_form.ml (434 lines) ✅
├── test_install_accuser_form.ml (406 lines) ✅
├── test_install_dal_node_form.ml (495 lines) ✅
├── test_instances_page.ml (260 lines) ✅
├── test_modal_interactions.ml (274 lines) ✅
└── tui_test_helpers.ml (9.8KB) ✅ w/ Mock System
Goal: Improve test quality, find bugs
Tasks:
- Add required field validation tests to all forms
- Add invalid input handling tests (bad ports, paths, names)
- Add edge case tests (long names, special chars, duplicates)
- Add error condition tests (binary not found, permissions)
- Add full workflow tests (install → start → verify)
Success Criteria:
- Each form has ≥5 validation tests
- Each form has ≥3 edge case tests
- ≥2 full workflow tests
- Find ≥1 real bug
Effort: 2-3 days
Coverage Impact: +1-2%
Quality Impact: HIGH
Goal: Enable testing of service operations
Tasks:
- Create
test/mocks/mock_systemd.mlinfrastructure - Mock service state registry (running, stopped, failed)
- Mock systemctl commands (start, stop, restart, enable)
- Failure injection (permission denied, timeouts, etc.)
- Integration with test helpers
- Document in TUI_TESTING_GUIDE.md
What This Unlocks:
- Testing instances_actions.ml (644 points, 0% → 60%)
- Testing cmd_instance.ml (453 points, 0% → 40%)
- Service lifecycle tests
- Error scenario tests
Effort: 3-5 days
Coverage Impact: +5% (~1,000 points)
Quality Impact: VERY HIGH (tests critical operations)
Current: 38% (7,988 / 20,935 points)
Target: 70% (14,655 / 20,935 points)
Gap: 6,667 points
Realistic Roadmap:
- #457: Validation tests → +100 points, HIGH quality
- #458: Systemd mocks → +1,000 points, unlock service testing
- Result: ~43% coverage
- #443: instances_render.ml tests → +500 points (+2.4%)
- #444: form_builder tests → +530 points (+3.6%)
- Complete modal helpers → +432 points
- Result: ~52% coverage
- CLI command tests → +500 points
- Additional TUI workflows → +500 points
- Service lifecycle tests → +500 points
- Result: ~58% coverage
- Deeper integration tests
- Error path coverage
- Edge case coverage
- Result: 65-70% coverage
Timeline:
- 50% coverage: 2-3 weeks
- 60% coverage: 4-6 weeks
- 70% coverage: 8-10 weeks
- Service operations (instances_actions.ml) - Blocked on #458
- CLI commands (cmd_*.ml) - Need integration tests
- Form infrastructure (form_builder.ml) - Need unit tests
- Instance rendering (instances_render.ml) - Need TUI tests
- Installation flows (installer/*.ml)
- Binary management
- Configuration parsing
- Navigation flows
- Type-only modules
- Unused features (snapshots page)
tui_test_helpers.ml: Mock System, setup/cleanup, assertionsHD(Headless_driver): Simulated terminal for TUI testing- Mock capabilities for file/directory operations
docs/TUI_TESTING_GUIDE.md: Complete TUI testing guidedocs/COVERAGE.md: Coverage infrastructure- Integration test examples in
test/integration/
✅ Mock System (file browser, file ops)
❌ Mock systemd (Issue #458)
❌ Mock binaries (could add)
❌ Mock network (could add)
- Pick a form to enhance (e.g.,
test_install_node_form.ml) - Add validation test cases:
let test_invalid_rpc_port () = setup_test_env (); HD.Stateful.init (module Install_node_form_v3); (* Navigate to RPC port field *) HD.feed_keys ["Down"; "Down"; "Down"]; (* Enter invalid port *) HD.feed_string "99999"; HD.feed_keys ["Enter"]; (* Verify error shown *) let screen = HD.get_screen_content () in assert_contains screen "Invalid port"; cleanup ()
- Run:
dune runtest - Document bugs found
- Create
test/mocks/mock_systemd.ml:type service_state = Stopped | Running | Failed of string let services : (string, service_state) Hashtbl.t = Hashtbl.create 17 let register_service name ~state = Hashtbl.replace services name state let start_service name = match Hashtbl.find_opt services name with | None -> Error "Service not found" | Some Stopped -> Hashtbl.replace services name Running; Ok () | Some Running -> Error "Already running" | Some (Failed _) -> Error "Service in failed state"
- Add hook in
src/common.mlto intercept systemctl calls in test mode - Create
test/test_instance_actions.mlwith tests - Document usage
- Tests find ≥3 real bugs
- All critical operations have test coverage
- Error paths tested
- Edge cases covered
- 50% overall coverage by Feb 14
- 60% overall coverage by Feb 28
- 70% overall coverage by Mar 31
- Test suite runs in <30 seconds
- CI completes in <15 minutes
- Coverage reports on all PRs
- No flaky tests
- #425: [META] Test Coverage Improvement: 27% → 70%
- #457: Improve form validation and error path coverage (NEW)
- #458: Build systemd mock infrastructure (NEW)
- #443: instances_render.ml tests (TO CREATE)
- #444: form_builder infrastructure tests (TO CREATE)
Last Updated: Jan 24, 2026
Next Review: When #457 or #458 complete