Test Temporal workflows with pytest, time-skipping

Temporal Python Testing Strategies

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

Temporal Python Testing Strategies cover

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)
Claude Codenpx skills add wshobson/agents --skill temporal-python-testing -g -a claude-code
Claude Code (manual)mkdir -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-testing
Windows (PowerShell)New-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" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md4.8 KB
  • resources/4 files · 45.1 KB
Read the files here
wshobson/4236bb95 files
SKILL.md
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:

  1. Unit: Workflows with time-skipping, activities with ActivityEnvironment
  2. Integration: Workers with mocked activities
  3. 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

  1. Time-Skipping - Month-long workflows test in seconds
  2. Mock Activities - Isolate workflow logic from external dependencies
  3. Replay Testing - Validate determinism before deployment
  4. High Coverage - ≥80% target for production workflows
  5. 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---
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---
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 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
Skill29 production-ready scripts for iOS app testing, buildingIos simulator skillconorluddy/ios-simulator-skill · by conorluddy29 production-ready scripts for iOS app testing, building, and automation. Provides semantic UI navigation, build automation, accessibility testing, and simulator lifecycle management. Optimized for AI agents with minimal token output.★ 1.3k GitHub starsSkillMoAI unified orchestrator for autonomous developmentmodu-ai/moai-adk · by modu-aiMoAI unified orchestrator for autonomous development. Routes natural language or subcommands (plan, run, sync, project, fix, loop, mx, feedback, review, clean, codemaps, gate, e2e, harness, goal, gtd, todo) to specialized agents.★ 1.2k GitHub starsSkillWrite Android unit, Compose UI, and Hilt-integrated testsAndroid Testing StandardsHoangNguyen0403/agent-skills-standard · by HoangNguyen0403Write Android unit, Compose UI, and Hilt-integrated tests. Use when designing test behavior with MockK or coroutine test utilities; defer database/WorkManager-specific recipes to the owning feature skill.★ 569 GitHub starsSkillImplementing any feature or bugfixTest-Driven Development (TDD)obra/superpowers · by obraUse when implementing any feature or bugfix, before writing implementation code★ 290k GitHub starsSkillToolkit for interacting with and testing local webWebapp testinganthropics/skills · by anthropicsToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.★ 178k GitHub starsPromptGuide to fixing bugs using a test-first approachTest first bug fixing approachf/prompts.chat · by Ilker UlusoyGuide to fixing bugs using a test-first approach, ensuring code reliability through systematic testing and implementation.New listing

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patternswshobson/agents · by wshobsonBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.★ 39.9k GitHub stars