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
Run Integration Tests
Run Functional Tests
Run All Tests
Test Options
Build Tags
Tests require specific build tags:test_dep- Enables test hooks (required for most tests)integration- Includes integration test dependenciesdisable_grpc_modules- Reduces binary size during tests
-tags disable_grpc_modules,test_dep
Test Timeout
Default timeout is 35 minutes (configurable viaTEST_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:Code Coverage
Generate coverage reports:Unit Test Coverage
Integration Test Coverage
Functional Test Coverage
.testoutput/ and available on Codecov.
Test Configuration
Build Tags
test_dep- Enables test hooks implementation for production code paths that are difficult to testTEMPORAL_DEBUG- Extends functional test timeouts for debugging sessionsdisable_grpc_modules- Disables gRPC modules for faster compilation
Environment Variables
Logging:TEMPORAL_TEST_LOG_FORMAT- Output format (jsonorconsole)TEMPORAL_TEST_LOG_LEVEL- Log verbosity (debug,info,warn,error,fatal)
TEMPORAL_TEST_OTEL_OUTPUT- File path for OTEL trace output on test failures
TEMPORAL_TEST_SHARED_CLUSTERS- Number of shared test clusters (default varies)TEMPORAL_TEST_DEDICATED_CLUSTERS- Number of dedicated test clusters (default varies)
TEMPORAL_TEST_DATA_ENCODING- Persistence encoding (proto3orjson, default:proto3)
CGO_ENABLED- Set to0to disable CGO for faster builds (default:0)
Writing Tests
See the development guidelines for best practices on writing tests. Key test utilities:Test Cluster
Usetestcore.NewEnv(t) for functional tests:
Test Variables
Usetestvars 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:integration tag:
OpenTelemetry Tracing
Debug tests using OTEL traces:localhost:3000.
See tracing.md for more details.
Fault Injection Tests
Run functional tests with fault injection enabled: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 uset.Parallel() unless there’s a specific reason not to:
//parallelize:ignore comment.