testing-conventions
Enforces testing standards when writing unit tests, integration tests, or agent evaluation tests. Covers test directory structure, naming conventions, fixture and setup patterns, mocking strategy, async testing, coverage requirements, and LLM-as-judge evaluation. Language-specific conventions (Python/pytest, Java/JUnit, C#/xUnit, React/Vitest) are loaded from bundled reference packs. Use this skill when writing tests, creating test files, setting up fixtures, mocking services, or reviewing test code for standards compliance.
- License 许可
- MIT
- 最近更新
- 2026-04-20
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- testing-conventions
- description
- Enforces testing standards when writing unit tests, integration tests, or agent evaluation tests. Covers test directory structure, naming conventions, fixture and setup patterns, mocking strategy, async testing, coverage requirements, and LLM-as-judge evaluation. Language-specific conventions (Python/pytest, Java/JUnit, C#/xUnit, React/Vitest) are loaded from bundled reference packs. Use this skill when writing tests, creating test files, setting up fixtures, mocking services, or reviewing test code for standards compliance.
02 资源文件 5
- 参考文档references/checklist.md1.7 KB
- 参考文档references/csharp/checklist.md1.5 KB
- 参考文档references/java/checklist.md1.5 KB
- 参考文档references/python/checklist.md2.5 KB
- 参考文档references/react/checklist.md2.0 KB
03 SKILL.md 正文
Testing Standards
Standards for testing across your services. Tests follow a layered strategy: fast unit tests for isolated logic, integration tests for service interactions, and agent evaluation tests for LLM quality gates in CI/CD.
Bundled references (read when you need the checklist):
references/checklist.md— Universal test review checklistreferences/<language>/checklist.md— Language-specific test checklist
Where <language> is python, java, csharp, or react — determined by the project's lao.config.yaml or auto-detected at pipeline start. Multi-language projects load all detected packs; apply each to files of its language.
See PROJECT.md for service-specific test directory structure, test commands, evaluation dataset details, and CI pipeline integration.
Test Directory Structure
Tests mirror the source layout and are separated by type:
test/ (or tests/)
unit/
<module_dirs>/ # Mirror source directory structure
test_<module>.* # One test file per source module
integration/
test_<feature>.* # Feature-level integration tests
Key rules:
- File naming mirrors the source file it tests
- Directory structure mirrors the source tree
- Unit tests and integration tests in separate directories
- Test configuration specifies default test path (usually unit tests)
Test Markers / Categories
Three categories drive the test pyramid:
| Category | Purpose | Speed | External Deps |
|---|---|---|---|
| Unit | Isolated logic, no external dependencies | Fast (ms) | None |
| Integration | Service interactions, mocked infrastructure | Medium (s) | Mocked or containerized |
| Agent Evaluation | LLM-based quality assessment | Slow (min) | LLM API access |
Agent evaluation tests are excluded from regular test runs and execute separately in CI.
See references/<language>/checklist.md for how to mark tests in your language's framework.
Fixture and Setup Conventions
Unit test fixtures — minimal, no external deps
- Create minimal configuration with external integrations disabled
- Fixtures provide pre-built objects (mock requests, contexts, configs)
- Each test is independent — no ordering dependencies between tests
Integration test fixtures — session-scoped, richer setup
- Expensive setup (app creation, client initialization) happens once per test session
- Infrastructure (secrets, auth) mocked before app creation
- Cleanup via teardown hooks for clients that need shutdown
See PROJECT.md for specific fixture implementations and mock targets.
Unit Test Patterns
Async testing
- Use the language's async test support for testing async/await code
- Mock async method calls appropriately (async mocks, not sync mocks)
- Verify async error propagation paths
Error mapping tests
Each external error type gets its own test verifying it maps to the correct domain exception. Don't combine multiple error types into one test.
Mocking strategy
- Mock at boundaries — external services, databases, third-party APIs
- Don't mock internal logic — if you need to mock the function you're testing, the design needs refactoring
- Prefer fakes over mocks for complex dependencies (in-memory database, fake HTTP server)
- One mock assertion per concept — don't verify every method call, verify the behavior you care about
Test naming
Tests describe the scenario, not the implementation:
Good: test_report_generation_fails_when_data_missing
createOrder_emptyItems_throwsBadRequest
ProcessOrderAsync_ValidRequest_ReturnsOrderWithId
Bad: test_report_1
testMethod3
Test1
Pattern: <method>_<scenario>_<expected result>
Integration Test Patterns
API endpoint testing
- Start the application in test mode with mocked external dependencies
- Send real HTTP requests through the test client
- Verify response status codes, body structure, and headers
- Test both success and error paths
Auth testing
- Verify that authenticated endpoints reject unauthenticated requests
- Verify that authorization scoping works (user A can't access user B's data)
- Test the gateway/middleware auth flow, not just the endpoint logic
Agent Evaluation Testing
LLM-as-a-judge evaluation integrated into CI/CD. This is a standard pattern for measuring agent quality.
How it works
- Golden dataset — test cases with prompts and reference answers
- Agent invocation — run the agent against each test case
- Multi-judge evaluation — LLM judges score responses on configurable dimensions (correctness, hallucination, tool usage)
- Quality gates — pass/fail based on configurable thresholds
- Metrics reporting — results published for tracking over time
Evaluation config
{
"dataset_name": "agent-golden-dataset",
"agent_name": "my-agent",
"eval_mode": "offline",
"judges": [
{"type": "llm", "name": "correctness", "prompt": "CORRECTNESS_PROMPT", "threshold": 0.7},
{"type": "llm", "name": "hallucination", "prompt": "HALLUCINATION_PROMPT", "threshold": 0.8},
{"type": "code", "name": "tool_call", "function": "tool_call_evaluator"}
],
"primary_metric": "WEIGHTED_AVG",
"pm_quality_acceptance_threshold": 0.7
}
Test dataset format
prompt,reference,tools_called
"What is the product?","The product is...","[]"
"How do I perform action X?","Go to Settings > Action X","[""knowledge_retriever""]"
See PROJECT.md for the specific dataset, judges, thresholds, and CI pipeline integration for agent evaluation.
Coverage Requirements
- Line coverage: >=85% for new code
- Branch coverage: measured and reported alongside line coverage
- Coverage is not a goal in itself — test quality matters more than coverage percentage
- Tests should verify behavior, not just execute code paths
- Assertions must be meaningful — not just "it didn't crash"
Before committing tests, consult references/checklist.md and references/<language>/checklist.md for the verification checklist.
04 同仓库更多 Skills
extra-role
A custom project-specific role for testing
compliance-review
Ensures regulatory compliance for financial services
extra-role
A custom role missing applies_to for testing
shipping
Shipping workflow for platform services. Use this skill when creating pull requests, pushing code for review, updating Jira tickets to reflect PR status, or completing the ship cycle for a feature or bugfix. Trigger this skill when the user says things like "open a PR," "create a pull request," "ship this," "push for review," "update the ticket," "mark this as ready for review," or "I'm done with this feature" — even if they don't explicitly say "shipping." Also trigger when the user wants to transition a Jira ticket status after code changes are ready.
security-standards
Enforces security standards when writing or reviewing code that handles authentication, secrets, sensitive data, API boundaries, or compliance concerns. Covers secrets manager integration, encryption at rest and in transit, IAM authentication and least-privilege authorization, OWASP Top 10 secure coding (including prompt injection), dependency vulnerability management, API security (auth, validation, rate limiting), PII and sensitive data protection in logs and traces, and regulatory compliance (CCPA/GDPR). Use this skill when adding endpoints, handling user data, managing secrets, reviewing for vulnerabilities, configuring auth, working with LLM prompts that accept user input, setting up deployment security, or assessing compliance. Also use when DAST findings need remediation.
product-manager
Product management workflows: write PRDs and spec documents, create user stories with acceptance criteria and T-shirt sizing, plan and prioritize roadmaps by quarter, run competitor and market analysis with live web research, and review Figma designs against PRD requirements for UX consistency. Use this skill whenever the user mentions PRDs, product requirements, user stories, acceptance criteria, story points, roadmaps, feature prioritization, competitor analysis, market research, or reviewing designs against specs — even if they don't explicitly say "product management." Also trigger when the user wants to create Jira-ready tickets, publish specs to Confluence, or audit Figma mockups for missing states.