writing-good-tests
Guidance for writing, reviewing, and refactoring software tests, focusing on integration strategies, condition-based waiting, and professional mocking patterns.
Introduction
This skill provides an authoritative framework for professional software testing, derived from best practices in modern development. It is designed for developers, QA engineers, and technical leads who need to improve the reliability of their test suites and reduce test flakiness. The core philosophy emphasizes testing actual behavior rather than implementation details, prioritizing high-confidence integration tests over brittle unit tests. Users gain access to structured methodologies for common testing challenges, including race condition mitigation and external dependency management.
-
Principles for writing durable tests that resist refactoring breakage, following the Kent C. Dodds philosophy of behavior-driven verification.
-
Standardized Arrange-Act-Assert (AAA) or Given-When-Then patterns to ensure test clarity and maintainability.
-
Implementation of robust condition-based polling functions to replace unreliable arbitrary timeouts, specifically avoiding flakiness in asynchronous code.
-
Advanced mocking strategies, including the 'Don't Mock What You Don't Own' rule, and distinguishing between managed and unmanaged dependencies to improve test design.
-
Clear identification of testing anti-patterns such as testing mock existence, incomplete mock structures, and the usage of test-only production code methods.
-
Intended for use during pull request reviews or initial test architecture design phases.
-
Use the provided waitFor utility functions to handle asynchronous event or state changes instead of hard-coded sleep timers.
-
Always evaluate if a dependency is 'managed' (internal database/file system) or 'unmanaged' (external APIs/services) before deciding on a mocking strategy.
-
Prioritize integration tests to gain the best confidence-to-cost ratio throughout the development lifecycle.
-
Review tests against the identified anti-patterns to ensure you are validating real software behavior and not just asserting on test infrastructure internals.
Repository Stats
- Stars
- 178
- Forks
- 23
- Open Issues
- 1
- Language
- Python
- Default Branch
- main
- Sync Status
- Idle
- Last Synced
- May 1, 2026, 08:22 AM