Testing¶
jott has 478 tests covering task management, command handling, UI components, and integrations.
Running Tests¶
# Run all tests
make test
# Run with coverage report
make test-cov
# Run a specific test file
pytest tests/test_jot.py -v
# Run a specific test class
pytest tests/test_jot.py::TestTaskManager -v
# Run a specific test
pytest tests/test_jot.py::TestTaskManager::test_add_task -v
Test Files¶
File |
Coverage |
|---|---|
|
Core TaskManager, App, end-to-end flows |
|
Dispatch table and key mapping |
|
Fuzzy-search picker widget |
|
Keyboard input handling |
|
CommandHandler and its mixins |
|
Color and style definitions |
|
Task editing edge cases |
|
Today filter and date-based features |
|
Fuzzy match algorithm |
|
Highlight color picker and task ID highlighting |
|
Google Calendar notes import |
|
Subtask sync, parent/child indicators, collapse/expand |
|
Terminal-width-aware text wrapping |
Writing Tests¶
Write tests for all new features
Update existing tests when modifying functionality
Aim for meaningful coverage (project target: 60%+)
Use descriptive test names:
def test_task_manager_prevents_duplicate_ids():
"""Ensure TaskManager generates unique IDs even with collisions."""
Test Isolation for ProjectRegistry¶
Warning
Always pre-create an empty registry file before constructing
ProjectRegistry in tests. Otherwise _auto_discover() loads all
real projects from ~/projects/ and tests can write to real
.jot.json files.
def test_project_registry(tmp_path):
reg_file = tmp_path / '.jot-projects.json'
reg_file.write_text('{}') # CRITICAL: prevents auto-discovery
registry = ProjectRegistry(registry_file=str(reg_file))
# ... test logic ...
This pattern is mandatory for any test that instantiates
ProjectRegistry.
Test Requirements for Pull Requests¶
All pull requests must:
Include tests for new functionality
Pass all existing tests
Maintain or improve code coverage
Not introduce test warnings
Bug Fix Workflow¶
Write a test that reproduces the bug (should fail)
Fix the code
Run the test (should pass)
Only then claim the fix is complete