测试自动化 — 自动运行测试(在 CI/CD 中)而不是手动运行 — 对于大规模的快速、可靠、频繁测试至关重要。有效地构建测试自动化涉及选择要自动化的内容、构建可维护的自动化以及将其集成到开发流程中。
要自动化的内容(以及不要自动化的内容)
AUTOMATE:
✓ REGRESSION tests (run constantly to catch breakage) — the biggest win
✓ Repetitive, stable, frequently-run tests; unit/integration tests; critical flows
DON'T necessarily automate:
✗ Exploratory testing, usability, one-off checks, highly unstable/changing features
→ manual testing still has a place (exploratory, UX, edge judgment)
→ Automate what's repetitive and valuable to run often; not everything.
构建可维护的自动化
✓ Follow the test PYRAMID (mostly fast unit tests; few E2E) → fast, stable automation
✓ Keep tests INDEPENDENT, deterministic, and FAST (avoid flakiness — it kills automation
value)
✓ Use good ABSTRACTIONS (e.g. Page Object Model for UI tests) → maintainable, DRY
✓ Manage TEST DATA and environments (clean, consistent, reproducible)
✓ Treat test code as REAL code (review it, refactor it, keep it clean)
