home / skills / dasien / claudemultiagenttemplate / test-design-patterns
This skill helps you design robust tests by applying AAA, fixtures, and mocks to create maintainable, reliable Python test suites.
npx playbooks add skill dasien/claudemultiagenttemplate --skill test-design-patternsReview the files below or copy the command above to add this skill to your agents.
---
name: "Test Design Patterns"
description: "Apply testing patterns like AAA (Arrange-Act-Assert), mocking, fixtures, and parameterization for maintainable test suites"
category: "testing"
required_tools: ["Read", "Write", "Bash"]
---
# 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
1. **AAA Pattern** - Arrange-Act-Assert structure
2. **Test Fixtures** - Reusable test data and setup
3. **Mocking/Stubbing** - Isolate units under test
## Approach
1. **Arrange**: Set up test data and conditions
2. **Act**: Execute the code being tested
3. **Assert**: Verify expected outcomes
4. Use descriptive test names
5. Keep tests independent and isolated
## Example
**Context**: Testing a task creation function
````python
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 togetherThis skill teaches proven test design patterns to build maintainable, reliable Python test suites for multi-agent systems and automated workflows. It emphasizes clear structure, isolation, and reuse so tests remain readable and resilient as code evolves. The guidance targets unit, integration, and system tests for task queues, agents, and related components.
The skill inspects test scenarios and recommends patterns like Arrange-Act-Assert, fixtures, mocking/stubbing, and parameterization to organize test logic. It shows how to extract reusable setup into fixtures, replace external dependencies with mocks, and structure assertions for clarity. Practical examples demonstrate applying patterns to task creation, agent interactions, and queue operations.
How many assertions should a test include?
Aim for one logical assertion per test. You can have multiple assertions that verify different facets of the same behavior, but avoid testing unrelated outcomes in one test.
When should I use mocks vs fixtures?
Use fixtures for reusable setup and shared test data. Use mocks to replace external dependencies or side effects (network, I/O, time) so tests remain fast and deterministic.