Skills · Coding

Temporal Python Testing Strategies

Unverified30/40

Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.

Originally by wshobson · MIT

Claude CodePartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
CursorPartialPlain prose you can paste in — but no Cursor rules file
CodexPartialPlain prose you can paste in — but no AGENTS.md
Gemini CLIPartialPlain prose you can paste in
CopilotPartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add temporal-python-testing

This command does not work yet — the CLI is still being built. Until then, use Raw in the reader below to take the file.

Who is stuck, and on what

Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.

The whole source

No sign-in, no blur, nothing truncated
temporal-python-testing/SKILL.md159 lines4.8 KBRawView on GitHub
Frontmatter — 2 properties
nametemporal-python-testing
descriptionTest Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.
1---
2name: temporal-python-testing
3description: Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.
4---A5No allowed-tools declared — no way to tell what this skill may touch
5 
6# Temporal Python Testing Strategies
7 
8Comprehensive testing approaches for Temporal workflows using pytest, progressive disclosure resources for specific testing scenarios.
9 
10## When to Use This Skill
11 
12- **Unit testing workflows** - Fast tests with time-skipping
13- **Integration testing** - Workflows with mocked activities
14- **Replay testing** - Validate determinism against production histories
15- **Local development** - Set up Temporal server and pytest
16- **CI/CD integration** - Automated testing pipelines
17- **Coverage strategies** - Achieve ≥80% test coverage
18 
19## Testing Philosophy
20 
21**Recommended Approach** (Source: docs.temporal.io/develop/python/testing-suite):
22 
23- Write majority as integration tests
24- Use pytest with async fixtures
25- Time-skipping enables fast feedback (month-long workflows → seconds)
26- Mock activities to isolate workflow logic
27- Validate determinism with replay testing
28 
29**Three Test Types**:
30 
311. **Unit**: Workflows with time-skipping, activities with ActivityEnvironment
322. **Integration**: Workers with mocked activities
333. **End-to-end**: Full Temporal server with real activities (use sparingly)
34 
35## Available Resources
36 
37This skill provides detailed guidance through progressive disclosure. Load specific resources based on your testing needs:
38 
39### Unit Testing Resources
40 
41**File**: `resources/unit-testing.md`
42**When to load**: Testing individual workflows or activities in isolation
43**Contains**:
44 
45- WorkflowEnvironment with time-skipping
46- ActivityEnvironment for activity testing
47- Fast execution of long-running workflows
48- Manual time advancement patterns
49- pytest fixtures and patterns
50 
51### Integration Testing Resources
52 
53**File**: `resources/integration-testing.md`
54**When to load**: Testing workflows with mocked external dependencies
55**Contains**:
56 
57- Activity mocking strategies
58- Error injection patterns
59- Multi-activity workflow testing
60- Signal and query testing
61- Coverage strategies
62 
63### Replay Testing Resources
64 
65**File**: `resources/replay-testing.md`
66**When to load**: Validating determinism or deploying workflow changes
67**Contains**:
68 
69- Determinism validation
70- Production history replay
71- CI/CD integration patterns
72- Version compatibility testing
73 
74### Local Development Resources
75 
76**File**: `resources/local-setup.md`
77**When to load**: Setting up development environment
78**Contains**:
79 
80- Docker Compose configuration
81- pytest setup and configuration
82- Coverage tool integration
83- Development workflow
84 
85## Quick Start Guide
86 
87### Basic Workflow Test
88 
89```python
90import pytest
91from temporalio.testing import WorkflowEnvironment
92from temporalio.worker import Worker
93 
94@pytest.fixture
95async def workflow_env():
96 env = await WorkflowEnvironment.start_time_skipping()
97 yield env
98 await env.shutdown()
99 
100@pytest.mark.asyncio
101async def test_workflow(workflow_env):
102 async with Worker(
103 workflow_env.client,
104 task_queue="test-queue",
105 workflows=[YourWorkflow],
106 activities=[your_activity],
107 ):
108 result = await workflow_env.client.execute_workflow(
109 YourWorkflow.run,
110 args,
111 id="test-wf-id",
112 task_queue="test-queue",
113 )
114 assert result == expected
115```
116 
117### Basic Activity Test
118 
119```python
120from temporalio.testing import ActivityEnvironment
121 
122async def test_activity():
123 env = ActivityEnvironment()
124 result = await env.run(your_activity, "test-input")
125 assert result == expected_output
126```
127 
128## Coverage Targets
129 
130**Recommended Coverage** (Source: docs.temporal.io best practices):
131 
132- **Workflows**: ≥80% logic coverage
133- **Activities**: ≥80% logic coverage
134- **Integration**: Critical paths with mocked activities
135- **Replay**: All workflow versions before deployment
136 
137## Key Testing Principles
138 
1391. **Time-Skipping** - Month-long workflows test in seconds
1402. **Mock Activities** - Isolate workflow logic from external dependencies
1413. **Replay Testing** - Validate determinism before deployment
1424. **High Coverage** - ≥80% target for production workflows
1435. **Fast Feedback** - Unit tests run in milliseconds
144 
145## How to Use Resources
146 
147**Load specific resource when needed**:
148 
149- "Show me unit testing patterns" → Load `resources/unit-testing.md`
150- "How do I mock activities?" → Load `resources/integration-testing.md`
151- "Setup local Temporal server" → Load `resources/local-setup.md`
152- "Validate determinism" → Load `resources/replay-testing.md`
153 
154## Additional References
155 
156- Python SDK Testing: docs.temporal.io/develop/python/testing-suite
157- Testing Patterns: github.com/temporalio/temporal/blob/main/docs/development/testing.md
158- Python Samples: github.com/temporalio/samples-python
159 

Reviews

Installed this one?Write the first review and take the Trailblazer badge.

Reviews only open after a real install, so this is empty — and we leave it empty rather than invent one.

Alternatives

Also in Coding