Temporal Python Testing Strategies
Unverified●30/40Claude Code◐PartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor◐PartialPlain prose you can paste in — but no Cursor rules file
Codex◐PartialPlain prose you can paste in — but no AGENTS.md
Gemini CLI◐PartialPlain prose you can paste in
Copilot◐PartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add temporal-python-testingWho 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
Frontmatter — 2 properties
| 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. |
| 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 | ---A5 — No allowed-tools declared — no way to tell what this skill may touch |
| 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 | 1. **Unit**: Workflows with time-skipping, activities with ActivityEnvironment |
| 32 | 2. **Integration**: Workers with mocked activities |
| 33 | 3. **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 | ```python |
| 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 | ```python |
| 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 | 1. **Time-Skipping** - Month-long workflows test in seconds |
| 140 | 2. **Mock Activities** - Isolate workflow logic from external dependencies |
| 141 | 3. **Replay Testing** - Validate determinism before deployment |
| 142 | 4. **High Coverage** - ≥80% target for production workflows |
| 143 | 5. **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.
Alternatives
Subagent Driven DevelopmentUse when executing implementation plans with independent tasks in the current session◐◐◐◐◐●36/40Python Code Style & DocumentationPython code style, linting, formatting, naming conventions, and documentation standards. Use when writing new code, reviewing style, configuring linters, writing docstrings, or establishing project standards.◐····●35/40Competitor Price Analysis 💲Competitor pricing strategy analysis and market positioning. Price mapping, pricing gaps identification, elasticity signals evaluation, and strategic pricing optimization. Use when the user asks about competitor pricing, price analysis, pricing strategy, or co◐····●34/40Competitor Price Tracker 📊Set up competitor price tracking and monitoring workflows. Track price changes, detect promotions, analyze pricing patterns, and get alerts for competitive price movements.◐····●34/40