TE
testing-best-practices
Guidelines for implementing effective and maintainable tests.
Install
mkdir -p .claude/skills/testing-best-practices && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13812" && unzip -o skill.zip -d .claude/skills/testing-best-practices && rm skill.zipInstalls to .claude/skills/testing-best-practices
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Guidelines for implementing effective and maintainable tests.61 charsno explicit “when” trigger
About this skill
Testing Best Practices
1. Hierarchy & Strategy
- E2E (End-to-End): Mandatory for every task.
- Stub Stage: Assert hardcoded values (verify structure).
- Impl Stage: Assert real logic (verify behavior).
- Unit: Cover edge cases, error handling, and specific algorithms.
- Regression: ALWAYS run the full test suite before submitting.
2. Critical Rules
- NO LLM MOCKING in Tests: Do not mock OpenAI/Anthropic calls in standard tests. Use recorded responses (VCR.py) or separate integration environments.
- Realism: Minimize mocks. Test real component capability where possible.
- Isolation: Tests must be independent. Database state should be reset between tests.
- Environment: Use the project's virtual environment (e.g.,
/opt/projects/.../venv).
3. Naming & Structure
- Clear Names:
test_shoud_return_error_when_invalid_input. - Organization: Mirror source structure (
src/auth->tests/auth). - Docstrings: specificy WHAT is being tested.
- Reference Examples:
- Python:
examples/pytest_structure.py - JavaScript:
examples/jest_structure.js
- Python:
4. Resources
- Templates: Use
assets/templates/test_boilerplate.pyto start new test files quickly.