Skip to main content
Temporal Server has a comprehensive test suite covering unit, integration, and functional tests.

Test Categories

Temporal defines three categories of tests:

Unit Tests

Tests with no external dependencies beyond the test target and Go mocks. Run fast and should have maximum coverage. Location: Throughout the codebase in *_test.go files

Integration Tests

Tests covering integration between the server and its dependencies (Cassandra, PostgreSQL, MySQL, Elasticsearch, etc.). Locations:
  • ./common/persistence/tests - Database integration tests
  • ./tools/tests - Database tool integration tests
  • ./temporaltest - Embedded server tests

Functional Tests

End-to-end tests covering the complete functionality of Temporal Server. Locations:
  • ./tests - Main functional test suite
  • ./tests/xdc - Cross-DC replication tests
  • ./tests/ndc - Named datacenter tests

Running Tests

Run Unit Tests

Unit tests do not require runtime dependencies.

Run Integration Tests

Integration tests require runtime dependencies. Start them first:

Run Functional Tests

Optionally specify persistence type and driver:

Run All Tests

This runs unit, integration, and functional tests sequentially.

Test Options

Build Tags

Tests require specific build tags:
  • test_dep - Enables test hooks (required for most tests)
  • integration - Includes integration test dependencies
  • disable_grpc_modules - Reduces binary size during tests
The Makefile automatically applies: -tags disable_grpc_modules,test_dep

Test Timeout

Default timeout is 35 minutes (configurable via TEST_TIMEOUT):

Race Detection

Race detection is enabled by default. To disable:

Test Shuffling

Test order is randomized by default. To disable:

Running Individual Tests

Run a specific test or test suite:
Examples:

Code Coverage

Generate coverage reports:

Unit Test Coverage

Integration Test Coverage

Functional Test Coverage

Coverage reports are written to .testoutput/ and available on Codecov.
Install the Codecov Browser Extension to see code coverage directly in GitHub PRs.

Test Configuration

Build Tags

  • test_dep - Enables test hooks implementation for production code paths that are difficult to test
  • TEMPORAL_DEBUG - Extends functional test timeouts for debugging sessions
  • disable_grpc_modules - Disables gRPC modules for faster compilation

Environment Variables

Logging:
  • TEMPORAL_TEST_LOG_FORMAT - Output format (json or console)
  • TEMPORAL_TEST_LOG_LEVEL - Log verbosity (debug, info, warn, error, fatal)
OpenTelemetry:
  • TEMPORAL_TEST_OTEL_OUTPUT - File path for OTEL trace output on test failures
Cluster Configuration:
  • TEMPORAL_TEST_SHARED_CLUSTERS - Number of shared test clusters (default varies)
  • TEMPORAL_TEST_DEDICATED_CLUSTERS - Number of dedicated test clusters (default varies)
Data Encoding:
  • TEMPORAL_TEST_DATA_ENCODING - Persistence encoding (proto3 or json, default: proto3)
CGO:
  • CGO_ENABLED - Set to 0 to disable CGO for faster builds (default: 0)

Writing Tests

See the development guidelines for best practices on writing tests. Key test utilities:

Test Cluster

Use testcore.NewEnv(t) for functional tests:

Test Variables

Use testvars package for generating test identifiers:

Task Poller

For end-to-end workflow testing:

Debugging Tests

IDE Debugging (GoLand)

Add build tags to “Go tool arguments” in Run/Debug configuration:
For integration tests, add the integration tag:
See GoLand Debugging documentation for details.

OpenTelemetry Tracing

Debug tests using OTEL traces:
Traces are available in Grafana at localhost:3000. See tracing.md for more details.

Fault Injection Tests

Run functional tests with fault injection enabled:
Or manually:

Test Helpers

softassert Package

softassert.That logs errors without stopping test execution:

testhooks Package

Injects test-specific behavior into production code (last resort - prefer mocking):

Test Parallelization

All tests should use t.Parallel() unless there’s a specific reason not to:
Automate parallelization:
Opt out with //parallelize:ignore comment.

Mixed Brain Tests

Tests that require CGO:

Troubleshooting

Tests Timeout

Increase timeout:

Tests Fail with “image not found”

Start dependencies:

Tests Pass Locally but Fail in CI

Ensure you’re using the correct build tags:

Clean Test Cache