This directory contains tests for the Blueprint project.
conftest.py: Contains pytest fixtures and shared test configuration.unit/: Contains unit tests for specific modules.
Run all tests using pytest:
# From project root
pytest
# Run with verbose output
pytest -v
# Run specific test file
pytest tests/unit/test_commit_generator.pyThe conftest.py file provides several fixtures that are useful for testing:
sample_git_diff: A sample git diff for testing diff parsing functionality.sample_ai_response: A sample AI service response for testing commit message generation.
When adding new tests:
- Use the pytest fixture system where appropriate.
- Mock all external dependencies (subprocess, network calls, etc.).
- Follow the Arrange-Act-Assert (AAA) pattern in test methods.
- Add docstrings to test functions that explain what's being tested.
To generate a test coverage report:
# From project root
pytest --cov=blueprint tests/
# Generate HTML report
pytest --cov=blueprint --cov-report=html tests/- Use
unittest.mock.patchto mock dependencies like subprocess calls and AIService. - When testing functions that call git commands, mock subprocess functions.
- For AI service interactions, mock the AIService class and its methods.