# Testing Rules

## Python (aiservice)

- Tests in `tests/` by feature: `optimizer/`, `testgen/`, `testgen_postprocessing/`, `testgen_instrumentation/`, `integration/`, `validators/`
- `@pytest.mark.asyncio` for async tests
- `pytest.ini` sets `DJANGO_SETTINGS_MODULE = aiservice.settings`
- `conftest.py` provides `normalize_code()` helper (AST parse/unparse for quote normalization)
- Test factories: `create_optimizer_context()`, `create_refiner_context()`
- Run tests: `uv run pytest` (all), `uv run pytest tests/path/test_file.py::test_name -v` (single)

## JS/TS (cf-api)

- Tests use dependency injection: `setXxxDependencies()` / `resetXxxDependencies()`

## PR Review

- **Always comment on**: Logic errors, security vulnerabilities, test name typos, breaking changes without migration
- **Never comment on**: Code style/formatting (linters handle it), "consider" suggestions, performance without profiling data
- Limit to 5-7 high-signal comments per review
