Test layout
Tests are co-located with source code in_test.go files. There is no separate test/ directory for unit tests.
TestKit
Thetestkit package provides helpers for actor-level testing. See TestKit for full documentation.
- TestKit β Creates a throwaway actor system. Provides Spawn, SpawnChild, Kill, Subscribe, NewProbe, NewGrainProbe, GrainIdentity.
- Probe β Test actor that records messages. Assertions: ExpectMessage, ExpectMessageOfType, ExpectNoMessage, ExpectTerminated; Send, SendSync; Watch, WatchNamed.
- GrainProbe β Similar for grain testing.
- MultiNodes β Multi-node cluster in-process for integration tests.
Integration tests
Tests needing real infrastructure (Consul, etcd) use testcontainers-go. Docker is required. Seediscovery/consul/
and discovery/etcd/ for patterns.
Mocks
Generated by mockery. Pre-built mocks inmocks/ cover Remoting, Cluster, Extension, Dependency, Provider. Use them to
isolate components in unit tests.
Conventions
- New public types or behavior changes should have test coverage
- Prefer TestKit probes for message-level assertions
- Use testcontainers for external infrastructureβdonβt assume services on the host