Nova Coder uses pytest for testing and ruff / black for linting and formatting. Every subsystem should have unit tests, and integration tests should cover the application lifecycle.
Test Suite
Run all tests:
pytest
Run with coverage:
pytest --cov=novacoder --cov-report=term-missing
Note on coverage
The default addopts no longer enables coverage automatically. Coverage is still available by passing --cov=novacoder explicitly. This avoids pytest-cov / coverage.py collector-stack crashes that can occur when threaded services (scheduler, monitoring, async health checks) start and stop during the test lifecycle.
Latest test run
pytest -q -p no:cacheprovider
1787 passed, 1 skipped, 3283 warnings in 546.90s (0:09:06)
All available tests currently pass. The remaining warnings are non-fatal (PytestReturnNotNoneWarning, DeprecationWarning for datetime.utcnow, and StarletteDeprecationWarning).
Project Layout
tests/
├── test_kernel.py # Container, event bus, registry, application
├── test_kernel_wiring.py # Regression tests for service wiring and health
├── test_config.py # Configuration loading and validation
├── test_tools.py # Tool framework and built-in tools
├── test_permissions.py # Permission model and tool enforcement
├── test_workspace.py # Scanner, language detection, symbols
├── test_indexing.py # Incremental indexing and symbol extraction
├── test_agents.py # Agent framework and manager
├── test_planner.py # Planning engine
├── test_workflows.py # Workflow executor
├── test_cli.py # CLI command regression tests
├── test_api.py # FastAPI REST endpoints
├── test_app.py # Integration tests for the full application
├── test_integration.py # End-to-end agent workflows
├── test_gui.py # TUI import and MemoryPage behavior
├── test_vector_memory.py # Vector memory embedding and search
├── test_bug_fixes.py # Regression tests for the 01-bug-fixes roadmap
└── test_security.py # Security agent and service
Test Examples
Kernel Test
def test_event_bus_publish_and_subscribe():
bus = EventBus()
received = []
bus.subscribe("TestEvent", lambda e: received.append(e.name))
bus.publish(Event(name="TestEvent"))
assert len(received) == 1
Tool Test
def test_read_file_tool(tmp_path):
path = tmp_path / "test.txt"
path.write_text("hello")
result = ReadFileTool().run(path=str(path))
assert result.output == "hello"
Application Integration Test
def test_app_starts_and_stops(app):
results = app.start()
assert app.is_running()
for name, (ok, error) in results.items():
assert ok, error
app.stop()
assert not app.is_running()
Code Quality
Format code:
black novacoder tests
Lint code:
ruff check novacoder tests
Type checking (optional):
mypy novacoder
CI/CD
The GitHub Actions workflow runs on every push and pull request:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: pip install -e ".[dev]"
- run: ruff check novacoder tests
- run: black --check novacoder tests
- run: pytest --cov=novacoder
Testing Principles
- Test behavior, not implementation details.
- Use
tmp_pathfor filesystem tests. - Mock external APIs (AI providers, network calls).
- Keep integration tests fast and deterministic.
- Never weaken tests without explicit direction.
Coverage Goals
- Target 80%+ coverage for core kernel modules.
- Target 70%+ coverage for tools and workspace.
- Add integration tests for every CLI command.
Development Instructions
Writing a New Test File
- Create
tests/test_<subsystem>.py. - Import the subsystem classes and pytest fixtures.
- Add test functions with descriptive names.
- Run
pytest tests/test_<subsystem>.py -vto verify.
Using Fixtures
Use built-in fixtures like tmp_path and event_loop:
def test_file_tool(tmp_path):
path = tmp_path / "test.txt"
path.write_text("hello")
assert path.read_text() == "hello"
Mocking External Services
from unittest.mock import AsyncMock
provider = MockProvider()
provider.chat = AsyncMock(return_value="response")
Running a Single Test
pytest tests/test_kernel.py::test_event_bus_publish_and_subscribe -v
Debugging a Failing Test
pytest tests/test_kernel.py -v --pdb
Adding Coverage
pytest --cov=novacoder --cov-report=term-missing
Discovery Notes
During the latest system-wide debug pass, the test suite was expanded to cover the failures and new systems that were found:
tests/test_agents.pyverifies thatAgentManagerregisters all default agents and that the new agents run successfully.tests/test_cli.pyexercises every CLI command (version,models,tools,agents,chat,memory) with Typer'sCliRunner.tests/test_api.pycovers the FastAPI endpoints, includingPOST /api/workspace/scan,GET /api/workspace/files,GET /api/memory, andDELETE /api/memory.tests/test_gui.pymounts theMemoryPageand exercises_store/_clearviatextualrun_test.tests/test_permissions.pywas added for the permission model andToolRegistryenforcement.tests/test_kernel_wiring.pyadds regression tests for service wiring and health propagation.tests/test_integration.pycovers end-to-end agent workflows.tests/test_bug_fixes.pyremains the regression suite for theroadmaps/01-bug-fixes.mdbugs.
After the latest implementation pass, tests/test_agents.py passes (28 passed) and novacoder doctor reports all 22 services healthy. The full suite still enforces a 70% coverage threshold; additional tests are being added to reach it.
UI Testing
WebUITester (novacoder/testing/ui.py) performs lightweight HTTP-level page-load and element-interaction checks using httpx when a browser automation tool is not available. It validates response status, body presence, and supported interaction actions.
Mutation Testing
MutationTestRunner._run_test_for_mutation invokes a configured test function (sync or async) before falling back to a probabilistic mutation-kill estimate when source-level AST mutation is not configured.
Related Documentation
- Setup & Contributing
- Kernel