3ccd94f661
Test Organization: - Create tests/unit/, tests/integration/, tests/system/ directories - Move existing tests into appropriate categories - Add pytest markers (@pytest.mark.unit, @pytest.mark.integration) Shared Fixtures: - Create conftest.py with SQLite engine (for unit tests) - Add PostgreSQL session fixture with transaction rollback - Add TestClient fixture for API tests Configuration: - Update pyproject.toml with asyncio_mode=auto - Add test markers and default addopts - Add aiosqlite dependency for SQLite support E2E Testing: - Initialize Playwright in e2e/ directory - Add playwright.config.ts - Create login flow E2E test Build: - Add test-unit, test-integration, test-system, test-e2e to Makefile - Update test target to run all categories - Add testing documentation to README Note: Some tests have import issues due to missing python-jose package in dev environment. This needs to be addressed separately.
54 lines
1.5 KiB
Markdown
54 lines
1.5 KiB
Markdown
|
|
## Testing Strategy
|
|
|
|
The project uses a three-tier testing approach:
|
|
|
|
### Test Categories
|
|
|
|
1. **Unit Tests** (`apps/api/tests/unit/`)
|
|
- Fast tests with no external dependencies
|
|
- Use SQLite in-memory database
|
|
- Run with: `make test-unit` or `pytest -m unit`
|
|
|
|
2. **Integration Tests** (`apps/api/tests/integration/`)
|
|
- Test API endpoints with database
|
|
- Use PostgreSQL with transaction rollback
|
|
- Run with: `make test-integration` or `pytest -m integration`
|
|
|
|
3. **System/E2E Tests** (`e2e/`)
|
|
- End-to-end tests using Playwright
|
|
- Test full user journeys
|
|
- Run with: `make test-e2e`
|
|
|
|
### Running Tests
|
|
|
|
```bash
|
|
# Run all tests (excludes system tests by default)
|
|
make test
|
|
|
|
# Run specific categories
|
|
make test-unit # Fast unit tests only
|
|
make test-integration # Integration tests with DB
|
|
make test-system # Full stack tests
|
|
make test-e2e # Browser-based E2E tests
|
|
|
|
# Inside Docker container
|
|
docker compose exec api pytest -v -m unit
|
|
docker compose exec api pytest -v -m integration
|
|
```
|
|
|
|
### Test Markers
|
|
|
|
Tests are marked with pytest markers:
|
|
- `@pytest.mark.unit` - Fast, isolated tests
|
|
- `@pytest.mark.integration` - Tests with database/external services
|
|
- `@pytest.mark.system` - Full stack tests
|
|
|
|
### Shared Fixtures
|
|
|
|
Common fixtures are in `apps/api/tests/conftest.py`:
|
|
- `sqlite_engine` - SQLite engine for unit tests
|
|
- `postgres_engine` - PostgreSQL engine for integration tests
|
|
- `db_session` - Database session with transaction rollback
|
|
- `test_client` - FastAPI TestClient instance
|