temporal-python-testing
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.
Author
Category
Development ToolsInstall
Download and extract to your skills directory
Copy command and send to OpenClaw for auto-install:
Temporal Python Testing
Use pytest and time-skipping to quickly test Temporal workflows, covering a complete testing strategy including unit tests, integration tests, replay tests, and local development environment setup.
Applicable Scenarios
WorkflowEnvironment to run a workflow that would normally take one month in just a few seconds, quickly verifying that the workflow logic is correct.Core Features
WorkflowEnvironment to automatically jump time, enabling workflows containing long waits (e.g., sleep, timers) to complete tests in milliseconds while preserving accurate time-related logic.Common Questions
How can time-skipping make a one-month workflow test finish in seconds?
In time-skipping mode, WorkflowEnvironment automatically skips all waiting times in the workflow (e.g., await asyncio.sleep(30 days)), executing only the actual business logic. When the workflow needs to wait for a certain time point, the test environment immediately advances time to that point instead of waiting in real time. This allows the original one-month workflow to complete within seconds while maintaining deterministic time logic.
When should replay testing be used?
Replay testing is mainly used for scenarios such as verifying before deployment that workflow code changes won’t break determinism, validating compatibility after upgrading the Temporal SDK version, and reproducing non-deterministic errors from the production environment. Replay tests re-execute the workflow using real Event History from production. If the new code produces a different decision path, the test fails immediately, helping you catch issues before deployment.
How to achieve the recommended 80% test coverage?
Adopt a layered testing strategy: use unit tests to cover core workflow logic branches (time-skipping makes these tests very fast), use integration tests to cover activity calls and error-handling paths, and use replay tests to cover all production workflow versions. Configure pytest-cov to check coverage regularly. Set coverage targets for critical business logic to ≥80%; for complex workflows, higher coverage is recommended.