- Current Coverage: ~60-65% (estimated)
- Target Coverage: 70%+
- Coverage Tools: pytest-cov with HTML reports
-
simulation/engine.py- Basic tests exist -
simulation/engine.py- Add tests for environmental stimuli integration -
simulation/agents.py- Improve agent behavior tests -
simulation/culture.py- Add more culture evolution tests -
simulation/economy.py- Add more economic system tests -
simulation/world.py- Add world state tests
-
simulation/memory/graph.py- Add graph memory tests -
simulation/memory/vector.py- Add vector memory tests -
simulation/memory/manager.py- Add memory manager tests
-
auth.py- Authentication tests added -
app.py- Add API endpoint tests -
app.py- Add error handling tests -
app.py- Add input validation tests
-
adapters/llm.py- Add LLM adapter tests -
adapters/neo4j.py- Add Neo4j adapter tests -
adapters/storage.py- Add storage adapter tests
- Test individual functions and methods
- Mock external dependencies
- Fast execution
- High coverage
- Test component interactions
- Use real dependencies where possible
- Test data flow
- Moderate execution time
- Test complete workflows
- Use real services
- Test user scenarios
- Slower execution
cd backend
pytest tests/ -vcd backend
pytest --cov=simulation --cov=adapters --cov=auth --cov-report=term-missing --cov-report=html tests/open htmlcov/index.html# Unit tests only
pytest -m unit tests/
# Integration tests only
pytest -m integration tests/
# Security tests
pytest -m security tests/backend/tests/
├── __init__.py
├── test_agents.py # Agent behavior tests
├── test_auth.py # Authentication tests
├── test_culture.py # Culture evolution tests
├── test_economy.py # Economic system tests
├── test_engine.py # Simulation engine tests
├── test_memory.py # Memory system tests (to be created)
├── test_api.py # API endpoint tests (to be created)
└── conftest.py # Shared fixtures (to be created)
- API Endpoints - Critical for production
- Input Validation - Security critical
- Authentication - Security critical
- Simulation Engine - Core functionality
- Memory Systems - Important for functionality
- Cultural Evolution - Core feature
- Economic System - Core feature
- Adapters - Can be tested with integration tests
- Utilities - Less critical paths
Create shared fixtures in conftest.py:
- Mock agents
- Mock world state
- Mock simulation engine
- Test configuration
- Sample stimuli data
- Sample agent configurations
- Sample world states
- Run coverage reports weekly
- Identify low-coverage areas
- Add tests for new features
- Update tests for changed code
- Set up CI/CD coverage reporting
- Track coverage trends
- Set coverage thresholds
- Block merges below threshold
- pytest: Test framework
- pytest-cov: Coverage plugin
- pytest-asyncio: Async test support
- pytest-mock: Mocking support
- coverage.py: Coverage measurement
- pytest-cov: Coverage integration
- HTML reports: Visual coverage reports
- Write tests before fixing bugs
- Test edge cases
- Test error conditions
- Keep tests fast
- Use descriptive test names
- Follow AAA pattern (Arrange, Act, Assert)
- ✅ Add authentication tests
- ⏳ Add API endpoint tests
- ⏳ Add memory system tests
- ⏳ Improve simulation engine tests
- ⏳ Add integration tests
- ⏳ Set up coverage CI/CD reporting