How to test Temporal workflows before they reach production
Testing a Temporal workflow before release means checking three things: the workflow logic runs correctly with its activities stubbed, the workflow and its activities work together on a real time-skipping test server, and the deployed system completes real executions end to end. Each layer catches a different class of failure, so none of them replaces the others. Teams need this discipline most when workflows run for days or months, because a change made today can be applied to executions that started long before the change, and a defect that only appears on a timer firing three weeks later will not show up in a quick manual check.
Unit tests exercise workflow code with activities mocked, so they run fast and point at logic errors such as wrong branching, bad retry handling in the workflow itself, or signal and query handlers that misbehave. Integration tests run the workflow and activities on the time-skipping test server, which lets sleep and timers advance without real waiting, so a 30-day timer can be verified in seconds. End-to-end tests run against a deployed environment with real workers, the real persistence and visibility stores, and the real frontend. They are the only layer that catches misconfigured task queues, namespace settings, authorization, codec failures and worker deployment problems. Confirm the current test server and SDK test helpers for your language in the Temporal documentation before you commit to a harness.
Replay testing is the complementary check for changes to workflow code. Unit and integration tests run new code against inputs you wrote, while replay runs new code against event histories that real executions produced, which is how non-determinism is caught before deployment. Put unit, integration and replay tests in CI so every change to workflow code is checked before merge, and keep end-to-end tests in a release pipeline against a non-production environment. Decide early who owns each layer, how histories are collected for replay, and which failures block a release.
What each test layer catches in Temporal code
Temporal application tests split into layers that each run at a different cost and fidelity. Each layer catches a different class of fault, so a team that relies on only one of them leaves the others open. The layers below run in parallel in CI, and the gaps between them are where production incidents usually start.
Unit tests with mocked activities
Unit tests run workflow code in isolation with activities replaced by mocks, so they check branching, signal handling, and how the workflow reacts to success or failure results. They are fast and need no server. They cannot prove that retry policies, timeouts, or timers behave as configured, because the mocks do not apply Temporal's retry logic. Check that each mocked activity returns both happy-path and error shapes that match the real activity contract.
Integration tests on the test server
The time-skipping test server runs real workflow and activity code against an in-process Temporal service, and it advances timers instead of waiting for them. This layer catches retry and timeout behavior, timer logic, and wiring between workers, task queues, and activity registration. It does not prove anything about persistence, visibility, or network behavior, because the test server does not model your production database or deployment. Confirm the SDK's current test server options with the SDK documentation for your language.
End-to-end tests against a running service
End-to-end tests start real workers and submit executions to a running Temporal Service, such as a self-hosted cluster in a staging environment that matches production's persistence and visibility stores. This layer catches environment faults: misconfigured namespaces, TLS and authorization settings, codec and encryption mismatches, and persistence or visibility problems. It is slower and more fragile, and it cannot prove behavior under production load or failure modes that staging does not reproduce.
Self-hosted deployment docsReplay checks against recorded histories
Replay checks rerun workflow code against event histories recorded from real executions to detect non-determinism before a deployment reaches production. They catch changes to workflow logic that would break in-flight executions, which the other layers can miss because they usually start fresh executions. They do not test activity behavior, external calls, or new workflows that have no history yet. Keep a set of representative histories in CI and treat any replay failure as a blocking change.
Test tooling by SDK language
The Go SDK documents a test framework for workflows and activities, which is the usual starting point for Temporal unit and integration tests in Go. Confirm the exact type names and helper methods against the Go SDK documentation for your version before you write tests against them.
- Activity mocking: Confirm how the test environment registers mock activity implementations and whether a test can assert on the order of activity calls.
- Time skipping: Confirm that timers fire without wall-clock waiting in your SDK version, so long-running workflows finish within a normal test run.
- Replay checks: Confirm whether the test environment can replay a recorded history, which is a separate check from unit tests.
- Determinism: Keep workflow code under test free of direct time, randomness, or goroutine calls that bypass SDK replacements, so tests reflect production rules.
- Local server runs: Confirm how integration tests connect to a local development server in CI.
Check which time-skipping test environment your Go SDK version provides and whether it matches the server version running in staging.
The Java SDK provides test support for workflows and activities, and Spring Boot applications add their own wiring for workers and beans. Confirm the test environment class, time-skipping behavior and Spring test annotations against the Java SDK documentation for the version your build uses.
- Spring test wiring: Confirm how the Spring Boot starter registers workers and activity beans in a test context, so tests do not start a production worker by accident.
- Mocked activities: Confirm how to replace activity implementations with test doubles while keeping workflow code unchanged.
- Time skipping: Confirm whether the test environment advances timers automatically and how to pause or step time for assertions.
- Interceptors in tests: Confirm whether interceptors registered for production also run in the test environment, since tracing or auth code can change test behavior.
- Dependency alignment: Pin the test artifact version to the SDK version used by your workers.
Check that the test server version you use is compatible with the Temporal Server version you plan to run in staging.
Python and TypeScript both run workflow code inside a sandbox or bundle that the tests must reproduce, so test setup has to match how production workers load code. Confirm the test environment classes, time-skipping support and sandbox settings against the documentation for your SDK version.
- Sandbox behavior: Confirm that tests run workflow code under the same sandbox rules as workers, including how pass-through modules are declared for imports.
- Async test fixtures: Confirm how pytest or the TypeScript test runner manages the test environment lifecycle, so servers and workers shut down cleanly between tests.
- Activity mocking: Confirm how to supply test activity implementations without changing the workflow definition.
- Time skipping: Confirm which time-skipping test environment each SDK provides and how workflows that wait on timers behave under it.
- Bundling in tests: For TypeScript, confirm whether tests use the same workflow bundling step as the worker build.
Check whether your sandbox or bundling configuration in tests matches the worker configuration you deploy.
The .NET SDK runs workers inside hosted services and follows deterministic task scheduling rules that tests need to respect. Confirm the test environment type, time-skipping support and test framework integration against the .NET SDK documentation for your version.
- Hosted service workers: Confirm how tests start workers from a hosted service or test host, so the same registration code runs in tests and production.
- Scheduling rules: Confirm that tests exercise workflow code under the scheduler rules, since code that depends on thread timing can pass locally and fail on workers.
- Activity mocking: Confirm how to replace activity implementations with test doubles in your chosen test framework.
- Time skipping: Confirm whether the test environment skips timers and how assertions wait for timer-driven states.
- Framework choice: Confirm which test framework and runner your SDK version supports in its examples.
Check that the test environment version aligns with the SDK and server versions in your deployment pipeline.
The Ruby and PHP SDKs are the most likely of the seven to have gaps in documented test tooling compared with the others, so teams using them should verify each capability before planning coverage. Confirm what each SDK version provides for workflow tests, time skipping and activity isolation against its own documentation.
- Test environment availability: Confirm whether a documented test environment with time skipping exists for your SDK version and what it covers.
- Activity isolation: Confirm whether activities can be invoked and checked outside a worker, which affects how much logic unit tests can cover.
- Rails and framework integration: For Ruby, confirm how the test suite starts workers and clients alongside the Rails test setup.
- PHP test runner: For PHP, confirm how the test runner manages worker lifecycle and whether timers can be controlled in tests.
- Fallback integration tests: Where time skipping is limited, confirm how to run integration tests against a local development server with shortened timers.
Check which tests you can automate at the unit level and which need an end-to-end environment before you set coverage targets.
How the test layers fit into a delivery pipeline
The pipeline starts at a code commit to a workflow repository. Fast unit tests run first, with activities mocked, and then integration tests run on the time-skipping test server. Replay tests run next against event histories captured from real executions, so a change that breaks determinism stops before it reaches a shared environment. Only builds that pass all three layers reach end-to-end tests on a deployed self-hosted or Temporal Cloud environment, and the release happens after that final gate.
Each test layer gates the next, from fast unit checks to end-to-end runs on a deployed environment.
Which test environment fits each goal
This table compares four places to test Temporal workflows: the mocked activity harness, the time-skipping test server, a local development server and a shared non-production environment. Read each row against the defect you are trying to catch, since speed and fidelity pull in opposite directions. The main takeaway is that no single environment covers logic, timing, deployment and integration risk at once.
| Environment | What it runs | Speed | Fidelity | When it fits |
|---|---|---|---|---|
| Mocked activity harness | Workflow code in the SDK test framework with activities replaced by mocks | Fast, runs in unit test suites on every commit | Low for activity behavior, no real persistence or worker | Checking workflow branching, signals, queries and retry decisions against stubbed results |
| Time-skipping test server | Temporal test server with real workflow execution and simulated time, with real or mocked activities | Fast enough for CI, timers advance without waiting | Medium, runs the Temporal engine logic but not your production persistence or visibility | Testing timers, sleeps, timeouts and multi-step workflows that depend on elapsed time |
| Local development server | A single-process Temporal server on your workstation with the Web UI | Interactive, real time, slower than the test server for long timers | Medium to high for SDK and workflow behavior, not your production topology | Developing and debugging workflows by hand, inspecting event histories and trying signals |
| Shared non-production environment | A self-hosted or Temporal Cloud namespace close to production configuration, with real workers and integrations | Slowest to set up and to reset, shared with other teams | High, confirm worker versions, codecs, auth and network paths match production | Release candidates, integration with downstream systems, and checks on authorization, payload encryption and deployment behavior |
Setting up a Temporal test suite
This sequence builds a Temporal test suite in layers, starting with fast unit tests and ending with replay checks, so each layer catches a different class of defect before workflow code reaches a shared environment. The result is a suite that runs in CI without depending on a public network path.
Choose the SDK test framework
The engineering lead confirms which official SDK the service uses and adopts that SDK's documented test tooling rather than building a custom harness. Start by reading the testing section of the SDK documentation for your language and listing which test helpers, mocks and time-skipping utilities it provides. The step is done when a trivial workflow runs under the chosen framework in a local test and the team agrees on the directory layout and naming for test files.
Write mocked-activity unit tests
Developers write unit tests that run each workflow function against mocked activities, so the test checks branching, retries handling, signal and timer logic and the order of activity calls without touching databases or external systems. Each mock returns fixed values or raises the failure types the workflow must handle. The step closes when the tests assert the final workflow result and the sequence of activity invocations for both the success path and at least one failure path.
Add time-skipping integration tests in CI
Developers add integration tests that run workflows against the Temporal test server with time skipping, so timers, sleeps and retry backoffs complete without waiting in real time. Real activity implementations or lightweight stand-ins run against this server, and the pipeline runs these tests on every change. The step is complete when a workflow with a multi-day timer finishes within a single test run and the CI job fails on a deliberately broken assertion.
Provision a non-production namespace and persistence
The platform team creates a dedicated non-production namespace on a self-hosted Temporal Service or a Temporal Cloud account, with persistence on a supported database that matches the production family as closely as the team can confirm. Access is granted through a service identity separate from production, and the Temporal server is confirmed to be reachable only from trusted internal networks, since the deployment documentation says services should not be exposed to the public internet. The step is done when a test worker connects to the namespace and the team can show that the endpoint does not resolve or respond from outside the test network.
Run end-to-end tests against the test environment
Developers deploy the worker build from CI into the non-production namespace and start real workflows through the client, including calls to real activity dependencies or sanctioned test doubles. These tests catch problems that unit and time-skipping tests miss, such as misconfigured task queues, wrong payload codecs, missing permissions and dependency version drift. The step closes when an end-to-end run starts a workflow, waits for completion through the client, and asserts the stored result and the visibility record for that execution.
Wire replay tests into the pipeline
Engineers add replay tests that load recorded event histories from completed executions and run the current workflow code against them, so a change that alters the command sequence fails before deployment. Histories are collected from the non-production namespace and stored as test fixtures, and the job runs whenever workflow code or the SDK version changes. The step is done when a deliberately reordered workflow step causes the replay job to fail with a non-determinism error and the job passes on unchanged code.
Gate merges on the full test sequence
The team configures the pipeline so that unit, time-skipping, end-to-end and replay stages all must pass before a merge or deployment, and records which stages are required and which are advisory. Ownership of the fixtures, namespace credentials and CI runners is written down, along with who reviews failures. The step is complete when a failing stage blocks the merge in a test branch and the team has documented how to rerun a single stage locally.
Why time skipping and determinism change what you test
Time skipping and determinism are the two properties that shape every Temporal test design. Timers, sleeps and retry backoffs in workflow code are recorded as durable events in the workflow history, so a test can run a workflow that waits days and finish in seconds, because the time-skipping test server in the Go and Java SDKs advances the workflow clock when nothing else is runnable. This makes it practical to assert on reminder timers, escalation paths and retry policies that would be impractical to wait for. Confirm the exact test server behavior and its availability in each SDK you use, since the test tooling is SDK-specific and the server is not a replica of a production cluster.
Determinism is the constraint that makes workflow code different from ordinary code under test. Workflow functions must produce the same commands when they are re-executed from history, so any direct call to the system clock, random numbers, network I/O or non-deterministic iteration can break replay long after a test passed. A unit test with mocked activities will not catch this, because it runs the workflow once and never replays a recorded history. Teams should treat a replay check against recorded histories as a required step whenever workflow code changes, and decide who owns the histories they replay against.
Time skipping also has limits that decide where a real service is still needed. Activities run outside the workflow clock, so behavior that depends on real latency, worker concurrency, task queue backlog, heartbeat timeouts or rate limits is not represented faithfully in a skipped-time test. Visibility queries, search attributes, namespace settings and authorization rules depend on the deployed Temporal Service and its persistence and visibility stores. Plan integration and end-to-end runs against a deployment that matches production configuration, and ask your platform team which persistence and visibility versions and authorizer settings that environment uses.
Security considerations for test environments
Test clusters for Temporal often hold real workflow history, payloads and credentials by accident, and they are rarely hardened like production. The cards below cover network placement, test data, access control and payload encryption, the four places where a test setup most often weakens security.
Keep test namespaces off public networks
The Temporal deployment documentation advises that Temporal services run on hosts that are not reachable from the public internet, with network access limited to trusted internal networks. Test clusters, including the ones CI pipelines spin up, should follow the same rule. Check that the frontend port is not exposed through a load balancer, an ingress or a shared runner network, and that developer laptops reach the test cluster only through the VPN or bastion your organization already uses.
Deployment docsUse synthetic data in tests
Test workflows should carry generated or anonymized inputs, never copies of production payloads. Workflow histories and activity inputs are stored in the persistence layer and can outlive the test run, so a single copied record can spread into test databases, logs and visibility indexes. Ask each team to document where test fixtures come from and to review any recorded event history before it is added to a shared repository.
Keep secrets out of test code
Activities that call external systems need credentials, and the test setup must not hard-code production keys or reuse them through environment variables copied from a deployment. Use separate sandbox credentials, inject them at runtime from a secrets store, and mock activities in unit tests so no real credential is needed. Confirm that CI logs do not print activity inputs, because a failing test can dump them.
Add access control to shared test clusters
If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. A shared test cluster that anyone on the internal network can reach is therefore open to any caller that can connect. Configure an Authorizer and a ClaimMapper so that test namespaces map to specific roles, and treat the absence of these settings as a finding before any shared environment is used.
Security docsHandle codecs and encryption in test data
Teams that encrypt payloads with a custom codec in production must run the same codec in tests, or test histories will not reflect production behavior. The inverse risk is more serious: a test codec key copied from production gives anyone with test-data access the ability to decrypt production payloads. Use a separate key for each environment, confirm that the codec server in test is reachable only by test clients, and check that test histories exported for replay remain encrypted at rest.
Questions teams ask about testing Temporal workflows
What drives the effort to build a Temporal test suite?
The largest drivers are how many workflows and activities the application has, how much logic lives in workflow code versus activities, and how many external systems the activities call. Workflows with branching, timers, signals and child workflows need more unit and integration cases than linear sequences. Versioning history matters too: code that has already run in production needs replay tests built from real event histories, which takes more setup than tests for new code. Teams should also count the test infrastructure they must maintain, such as fakes for external services, CI runners and a time-skipping test environment. Ask any partner to break the estimate down by workflow, activity and environment rather than quoting one number.
Can an internal engineering team test Temporal workflows on its own?
Yes, many teams do. Temporal's SDKs include test frameworks for workflow unit tests with mocked activities and for integration tests on a time-skipping test server, so the core skills are available in each language. What usually takes longer is the surrounding work: deciding which failures each test layer should catch, building fakes for external systems, wiring tests into CI, and keeping replay tests current as workflow code changes. Teams with an experienced Temporal developer and a clear test strategy often start in-house. Teams new to Temporal often choose a fixed-scope engagement to set up the framework and then hand over the suite with documentation.
How long does setting up Temporal workflow tests usually take?
Duration depends on the number of workflows, how many external dependencies need fakes, whether the team already runs CI pipelines that can host the tests, and how much existing workflow code must be covered. A single service with a few workflows is a different job from a platform with many task queues and long-running workflows already in production. Replay testing adds time because it needs real or representative event histories exported from a Temporal namespace. No duration is given here. Ask for a written plan that lists the workflows in scope, the test layers for each, the environment required and the handover deliverables, and check that the timeline follows from that list.
What does the testing work need from our engineers and infrastructure?
Engineers need working knowledge of the SDK language, the Temporal programming model and the determinism rules that the workflow code must follow. Someone who owns the application should review the test plan, because test design depends on business rules that only the team knows. On the infrastructure side, the team needs a CI environment where tests can run, access to a Temporal Service for integration or end-to-end runs, and a way to export workflow histories for replay tests. For self-hosted environments, the Temporal Service must run on hosts that are not reachable from the public internet, so test environments need private network paths to it. Confirm these prerequisites before scoping.
How does testing differ between self-hosted Temporal and Temporal Cloud?
Unit tests with mocked activities behave the same in both models because they run inside the SDK test framework without a live service. Integration tests on the time-skipping test server also run locally in both cases. The difference shows up in end-to-end tests and in the environments around them. With self-hosted Temporal, the team operates the test namespace, persistence and any visibility store, so test data cleanup, namespace setup and authorization settings are the team's responsibility. Self-hosted deployments default to a noopAuthorizer that allows every request unless an Authorizer is configured, so test environments should reflect the production security configuration. With Temporal Cloud, the vendor operates the service, and the team focuses on namespaces, credentials and connectivity. Temporal Cloud pay-as-you-go pricing starts at 50 US dollars per million actions, according to Temporal's pricing page, so end-to-end test volume is a cost line to plan. Ask about separate test namespaces and their action costs in either model.
Which kinds of defects does each Temporal test layer catch?
Unit tests with mocked activities catch logic errors in workflow code, such as wrong branching, mishandled retries and incorrect signal handling. Integration tests on the time-skipping test server catch timer behavior, child workflow coordination and activity interaction without waiting in real time. End-to-end tests against a real Temporal Service catch deployment and configuration issues, such as worker connectivity, namespace settings and codec behavior. Replay tests catch non-determinism introduced by code changes before they reach production. Each layer has limits, so a passing unit test does not prove a safe deployment. Ask a partner to map each critical workflow to the layers that cover it and to name the gaps that remain.
What should we ask for in a quote for Temporal testing work?
Ask for a written scope that names the SDK language, the workflows and activities in scope, the test layers for each, and the test environments needed. The quote should separate one-time work, such as framework setup and the initial suite, from recurring work, such as maintaining replay tests after each release. It should state what the client provides, including repository access, CI access, a Temporal environment and workflow histories, and what DeployOpen delivers, such as documentation and a handover session. Confirm how changes to scope are priced and who owns the test code after delivery. DeployOpen does not publish a price list, and a quote follows from the written scope.
How DeployOpen works on this
DeployOpen scopes Temporal test work from the workflows you run today and the changes you expect to make. We build the test layers that fit each workflow, run them in your own CI environment, and document how the suite is maintained after handover.
How we scope
- Inventory the workflows, activities and task queues that need unit, integration and end-to-end coverage
- Agree which Temporal SDK and test tooling the suite will use before work starts
- Define which failure modes each test layer must catch, such as non-determinism, retries and timeouts
- Record the CI systems, environments and access the suite needs in the written scope
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work begins
How we build
- Write unit tests with mocked activities for workflow logic and branching decisions
- Build integration tests on the time-skipping test server so timers and retries run quickly
- Add end-to-end tests against a deployed Temporal environment that matches your production configuration
- Wire replay checks and version gates into the pipeline so changes to workflow code are reviewed
- Keep test data, fixtures and secrets handling aligned with your organization's standards
How we hand over
- Deliver the test code in your repositories with a README covering how each layer runs
- Document which failures each test layer catches and which it does not, so gaps stay visible
- Provide a runbook for adding tests when new workflows or activities are introduced
- Walk your engineers through the suite and the CI jobs that execute it
- Hand over a findings list with any open items and the fixes applied during the engagement
How we support
- Support the suite after handover through a retainer if your team wants ongoing help
- Review test results and flaky tests as your Temporal SDK or server version changes
- Update the suite when workflow designs or versioning approaches change in your codebase
- Retainers can also cover continuous testing and upgrade work on the Temporal environment
- Confirm support terms, response expectations and included work in the written agreement

