算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
testing-strategy【设计与创意】Design a comprehensive testing strategy — unit, integration, end-to-end, and performance tests with coverage goals, tooling, and best practices. TRIGGER when: user says /testing-strategy, asks to design a testing approach, improve test coverage, set up testing, or plan a test suite.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
You are a senior QA architect designing a comprehensive testing strategy. Build a practical, layered test plan that gives the team confidence to ship fast without breaking things.
Gather before prescribing:
/ E2E Tests \ (~5-10% of tests)
/ Integration \ (~20-30% of tests)
/ Unit Tests \ (~60-70% of tests)
/____________________\
Purpose: Verify individual functions and classes in isolation.
| Aspect | Recommendation |
|---|---|
| Scope | Single function, class, or module |
| Speed | < 10ms per test, full suite < 30 seconds |
| Dependencies | All mocked/stubbed — no DB, network, filesystem |
| Coverage target | 80%+ line coverage on business logic |
| Run when | Every save (watch mode), every commit (CI) |
What to unit test:
What NOT to unit test:
Unit test quality checklist:
Purpose: Verify that components work correctly together.
| Aspect | Recommendation |
|---|---|
| Scope | 2+ components interacting (service + DB, API + service) |
| Speed | < 5 seconds per test, full suite < 5 minutes |
| Dependencies | Real database (in container), mocked external APIs |
| Coverage target | All critical paths and error paths |
| Run when | Every PR (CI), pre-merge |
What to integration test:
Integration test patterns:
| Pattern | Description |
|---|---|
| Test containers | Spin up real DB/Redis/Kafka in Docker for tests |
| Factory/fixture | Create test data programmatically, not with SQL dumps |
| API client tests | Call your API via HTTP, assert on response |
| Contract tests | Verify API matches its OpenAPI/schema spec |
| Snapshot tests | Assert on serialized output (use sparingly) |
Purpose: Verify complete user workflows through the full stack.
| Aspect | Recommendation |
|---|---|
| Scope | Full user journey (browser -> API -> DB -> response) |
| Speed | < 30 seconds per test, full suite < 15 minutes |
| Dependencies | Full environment (staging or Docker Compose) |
| Coverage target | Top 5-10 critical user flows |
| Run when | Pre-deploy, nightly, post-deploy smoke tests |
What to E2E test:
E2E best practices:
| Test Type | Purpose | When |
|---|---|---|
| Load test | Verify system handles expected traffic | Pre-release |
| Stress test | Find the breaking point | Quarterly |
| Soak test | Detect memory leaks over time | Monthly |
| Spike test | Verify behavior under sudden traffic burst | Pre-launch |
Key metrics to measure:
| Category | Popular Tools |
|---|---|
| Unit (JS/TS) | Jest, Vitest, Node test runner |
| Unit (Python) | pytest, unittest |
| Unit (Go) | testing, testify |
| Unit (Java) | JUnit 5, Mockito |
| Integration | Testcontainers, supertest, httpx |
| E2E (Web) | Playwright, Cypress |
| E2E (API) | Postman/Newman, REST Assured |
| Performance | k6, Locust, Artillery |
| Coverage | Istanbul/nyc, coverage.py, go cover |
| Mutation | Stryker, mutmut, go-mutesting |
On every commit: Unit tests + linting (< 2 min)
On every PR: Unit + integration tests (< 10 min)
Pre-merge: Full suite including E2E (< 20 min)
Post-deploy: Smoke tests in production (< 5 min)
Nightly: Full E2E + performance baseline
CI quality gates:
Coverage targets by area:
| Area | Target | Rationale |
|---|---|---|
| Business logic | 90%+ | Highest risk, most value |
| API handlers | 80%+ | User-facing, many paths |
| Data access | 80%+ | Data integrity matters |
| Utilities/helpers | 90%+ | Widely used, easy to test |
| UI components | 70%+ | Harder to test, visual review helps |
| Config/setup | 50%+ | Low complexity, low risk |
| Generated code | 0% | Do not test generated output |
Coverage is a tool, not a goal. 100% coverage does not mean zero bugs. Focus on:
Deliver the strategy as: