Test Temporal workflows with pytest, time-skipping
Temporal Python Testing Strategies

Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup.
--- name: temporal-python-testing description: 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. --- # Temporal Python Testing Strategies Comprehensive testing approaches for Temporal workflows using pytest, progressive disclosure resources for specific testing scenarios. ## When to Use This Skill - **Unit testing workflows** - Fast tests with time-skipping - **Integration testing** - Workflows with mocked activities - **Replay testing** - Validate determinism against production histories - **Local development** - Set up Temporal server and pytest - **CI/CD integration** - Automated testing pipelines - **Coverage strategies** - Achieve ≥80% test coverage
Overview
Comprehensive testing approaches for Temporal workflows using pytest, progressive disclosure resources for specific testing scenarios.
Manual install (npx, ZIP)
npx skills add wshobson/agents --skill temporal-python-testing -g -a claude-codemkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \
| tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/backend-development/skills/temporal-python-testingNew-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/93b370c759af81d8c507/temporal-python-testing.zip" -OutFile "$env:TEMP\temporal-python-testing.zip"; Expand-Archive "$env:TEMP\temporal-python-testing.zip" -DestinationPath "$HOME\.claude\skills" -ForceConnects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md4.8 KBresources/4 files · 45.1 KB
Read the files here
wshobson/
Show the full text159 lines
Temporal Python Testing Strategies
Comprehensive testing approaches for Temporal workflows using pytest, progressive disclosure resources for specific testing scenarios.
When to Use This Skill
- Unit testing workflows - Fast tests with time-skipping
- Integration testing - Workflows with mocked activities
- Replay testing - Validate determinism against production histories
- Local development - Set up Temporal server and pytest
- CI/CD integration - Automated testing pipelines
- Coverage strategies - Achieve ≥80% test coverage
Testing Philosophy
Recommended Approach (Source: docs.temporal.io/develop/python/testing-suite):
- Write majority as integration tests
- Use pytest with async fixtures
- Time-skipping enables fast feedback (month-long workflows → seconds)
- Mock activities to isolate workflow logic
- Validate determinism with replay testing
Three Test Types:
- Unit: Workflows with time-skipping, activities with ActivityEnvironment
- Integration: Workers with mocked activities
- End-to-end: Full Temporal server with real activities (use sparingly)
Available Resources
This skill provides detailed guidance through progressive disclosure. Load specific resources based on your testing needs:
Unit Testing Resources
File: resources/unit-testing.md
When to load: Testing individual workflows or activities in isolation
Contains:
- WorkflowEnvironment with time-skipping
- ActivityEnvironment for activity testing
- Fast execution of long-running workflows
- Manual time advancement patterns
- pytest fixtures and patterns
Integration Testing Resources
File: resources/integration-testing.md
When to load: Testing workflows with mocked external dependencies
Contains:
- Activity mocking strategies
- Error injection patterns
- Multi-activity workflow testing
- Signal and query testing
- Coverage strategies
Replay Testing Resources
File: resources/replay-testing.md
When to load: Validating determinism or deploying workflow changes
Contains:
- Determinism validation
- Production history replay
- CI/CD integration patterns
- Version compatibility testing
Local Development Resources
File: resources/local-setup.md
When to load: Setting up development environment
Contains:
- Docker Compose configuration
- pytest setup and configuration
- Coverage tool integration
- Development workflow
Quick Start Guide
Basic Workflow Test
import pytest
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import Worker
@pytest.fixture
async def workflow_env():
env = await WorkflowEnvironment.start_time_skipping()
yield env
await env.shutdown()
@pytest.mark.asyncio
async def test_workflow(workflow_env):
async with Worker(
workflow_env.client,
task_queue="test-queue",
workflows=[YourWorkflow],
activities=[your_activity],
):
result = await workflow_env.client.execute_workflow(
YourWorkflow.run,
args,
id="test-wf-id",
task_queue="test-queue",
)
assert result == expected
Basic Activity Test
from temporalio.testing import ActivityEnvironment
async def test_activity():
env = ActivityEnvironment()
result = await env.run(your_activity, "test-input")
assert result == expected_output
Coverage Targets
Recommended Coverage (Source: docs.temporal.io best practices):
- Workflows: ≥80% logic coverage
- Activities: ≥80% logic coverage
- Integration: Critical paths with mocked activities
- Replay: All workflow versions before deployment
Key Testing Principles
- Time-Skipping - Month-long workflows test in seconds
- Mock Activities - Isolate workflow logic from external dependencies
- Replay Testing - Validate determinism before deployment
- High Coverage - ≥80% target for production workflows
- Fast Feedback - Unit tests run in milliseconds
How to Use Resources
Load specific resource when needed:
- "Show me unit testing patterns" → Load
resources/unit-testing.md - "How do I mock activities?" → Load
resources/integration-testing.md - "Setup local Temporal server" → Load
resources/local-setup.md - "Validate determinism" → Load
resources/replay-testing.md
Additional References
- Python SDK Testing: docs.temporal.io/develop/python/testing-suite
- Testing Patterns: github.com/temporalio/temporal/blob/main/docs/development/testing.md
- Python Samples: github.com/temporalio/samples-python
| 1 | |
| 2 | name temporal-python-testing |
| 3 | description 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 | |
| 5 | |
| 6 | # Temporal Python Testing Strategies |
| 7 | |
| 8 | Comprehensive 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 | |
| 31 | **Unit**: Workflows with time-skipping, activities with ActivityEnvironment |
| 32 | **Integration**: Workers with mocked activities |
| 33 | **End-to-end**: Full Temporal server with real activities (use sparingly) |
| 34 | |
| 35 | ## Available Resources |
| 36 | |
| 37 | This 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 | |
| 90 | import pytest |
| 91 | from temporalio.testing import WorkflowEnvironment |
| 92 | from temporalio.worker import Worker |
| 93 | |
| 94 | @pytest.fixture |
| 95 | async def workflow_env(): |
| 96 | env = await WorkflowEnvironment.start_time_skipping() |
| 97 | yield env |
| 98 | await env.shutdown() |
| 99 | |
| 100 | @pytest.mark.asyncio |
| 101 | async 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 | |
| 120 | from temporalio.testing import ActivityEnvironment |
| 121 | |
| 122 | async 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 | |
| 139 | **Time-Skipping** - Month-long workflows test in seconds |
| 140 | **Mock Activities** - Isolate workflow logic from external dependencies |
| 141 | **Replay Testing** - Validate determinism before deployment |
| 142 | **High Coverage** - ≥80% target for production workflows |
| 143 | **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 |
Details
- Updated
- Sep 21, 2026
- License
- MIT
- Stars on the repo
- ★ 39,857
- Checked
- Source
- wshobson/agents ↗
- Creator
- wshobson · 179 listings
Similar skills
See all →
Skill29 production-ready scripts for iOS app testing, buildingIos simulator skill
SkillMoAI unified orchestrator for autonomous development
SkillWrite Android unit, Compose UI, and Hilt-integrated testsAndroid Testing Standards
SkillImplementing any feature or bugfixTest-Driven Development (TDD)
SkillToolkit for interacting with and testing local webWebapp testing
PromptGuide to fixing bugs using a test-first approachTest first bug fixing approachMore from wshobson
SkillMaster C/.NET backend development patterns for building
SkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliance
SkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Design
SkillMigrate from AngularJS to Angular using hybrid modeAngular migration
SkillUnderstand anti-reversing, obfuscationAnti reversing techniques
SkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patterns