Test Design Patterns
SKILL.md
Test Design Patterns
Purpose
Apply proven testing patterns to create maintainable, reliable test suites that effectively validate functionality.
When to Use
- Writing unit, integration, or system tests
- Organizing test code
- Creating test fixtures and data
- Designing test strategies
Key Capabilities
- AAA Pattern - Arrange-Act-Assert structure
- Test Fixtures - Reusable test data and setup
- Mocking/Stubbing - Isolate units under test
Approach
- Arrange: Set up test data and conditions
- Act: Execute the code being tested
- Assert: Verify expected outcomes
- Use descriptive test names
- Keep tests independent and isolated
Example
Context: Testing a task creation function
def test_add_task_with_valid_input_creates_task():
# Arrange
queue = TaskQueue()
task_data = {"title": "Test", "agent": "tester"}
# Act
task_id = queue.add_task(task_data)
# Assert
assert task_id is not None
assert queue.get_task(task_id).title == "Test"
Best Practices
- ✅ One logical assertion per test
- ✅ Descriptive test names explaining scenario
- ✅ Independent tests (no shared state)
- ❌ Avoid: Testing multiple unrelated things together