with one click
testing
Running and debugging tests in the Golem workspace. Use when writing tests, running specific tests, filtering tests, debugging test failures, or understanding test infrastructure.
Menu
Running and debugging tests in the Golem workspace. Use when writing tests, running specific tests, filtering tests, debugging test failures, or understanding test infrastructure.
| name | testing |
| description | Running and debugging tests in the Golem workspace. Use when writing tests, running specific tests, filtering tests, debugging test failures, or understanding test infrastructure. |
Tests use test-r. Each test file must import test_r::test or the tests will silently not run:
use test_r::test;
#[test]
fn my_test() {
// ...
}
Do not run cargo make test — it runs all tests and takes a very long time.
| Change Type | Test Command |
|---|---|
| Core logic, utilities | cargo make unit-tests |
| Worker executor functionality | cargo make worker-executor-tests |
| Service integration | cargo make integration-tests |
| CLI changes | cargo make cli-integration-tests |
Whenever tests are modified, always run the affected tests to verify they still pass before considering the task complete.
For running specific tests during development:
cargo test -p <crate> -- <test_name> --report-time
This project uses test-r which supports multiple filter arguments after --. Filters are OR-matched (a test runs if it matches any filter). Each filter is a substring match, not a regex.
Test names in test-r are module-qualified paths without the crate/binary name prefix. For example, --list shows golem_common::model::oplog::payload::tests::roundtrip_ipaddress or integration::plugins::oplog_processor, but the first segment (golem_common:: or integration::) is the crate/binary name and is not part of the filterable test name. The filterable name starts from the second segment.
# Run a single specific test by function name (substring match):
cargo test -p <crate> -- roundtrip_ipaddress --report-time
# Run a single specific test using module path (substring match, omit first segment):
cargo test -p <crate> -- payload::tests::roundtrip_ipaddress --report-time
# Run a single specific test with --exact (must use FULL module path, omitting first segment):
cargo test -p <crate> -- model::oplog::payload::tests::roundtrip_ipaddress --exact --report-time
# For integration tests where --list shows integration::plugins::oplog_processor:
cargo test -p integration-tests --test integration -- plugins::oplog_processor --exact --report-time
# Run multiple specific tests (filters go AFTER --, not before):
cargo test -p <crate> -- test_name_1 test_name_2 test_name_3 --report-time
# WRONG - do NOT include the first segment (crate/binary name) in filters:
# cargo test -p golem-common -- golem_common::model::oplog --report-time
# cargo test -p integration-tests --test integration -- integration::plugins::oplog_processor --report-time
# WRONG - --exact with just the function name (needs full module path minus first segment):
# cargo test -p <crate> -- roundtrip_ipaddress --exact --report-time
# WRONG - multiple filters before -- causes "unexpected argument" error:
# cargo test -p <crate> test1 test2 -- --report-time
# WRONG - regex patterns don't work (filters are substring matches, not regex):
# cargo test -p <crate> -- "test_a|test_b" --report-time
# cargo test -p <crate> -- "test_.*pattern" --report-time
Note: --list in test-r ignores filters and always lists all tests. Do not use --list to verify that filters are working. Instead, do a real run and check the filtered out count in the result line.
Use --nocapture when debugging tests:
cargo test -p <crate> -- <test> --nocapture
Always save test output to a file when running worker executor tests, integration tests, or CLI tests. These tests are slow and produce potentially thousands of lines of logs. Never pipe output directly to grep, head, tail, etc. — if you need to examine different parts of the output, you would have to re-run the entire slow test. Instead:
cargo test -p <crate> -- <test> --nocapture > tmp/test_output.txt 2>&1
# Then search/inspect the saved file as needed
grep -n "pattern" tmp/test_output.txt
Handling hanging tests: Load the debugging-hanging-tests skill for a step-by-step workflow.
Worker executor tests, integration tests, and CLI integration tests can depend on built WASM artifacts in test-components/. These .wasm files are no longer checked into the repository, so compiling the test components used by the selected tests is a separate prerequisite step before running the tests.
Use this workflow:
PrecompiledComponent or test component files the selected tests require.AGENTS.md, or run cargo make build-test-components if a broad rebuild is simpler.Load the modifying-test-components skill for targeted rebuilds, or rebuild-all-test-components for a full rebuild.
Add a #[timeout] attribute for tests that should fail rather than hang:
use test_r::test;
use test_r::timeout;
#[test]
#[timeout("30s")]
async fn my_test() {
// ...
}
Choose a timeout generous enough for normal execution but short enough to fail quickly when hung (30s–60s for most tests, up to 120s for complex integration tests).
Developing, testing, and running Golem skill tests with the skill test harness. Use when creating new skills, writing scenario YAML files, running skill tests locally, or debugging skill test failures.
Cutting a new docs version, promoting next to a release, and managing versioned documentation content under docs/src/content/. Use when releasing a new Golem version, backporting docs fixes to an older release, renaming a docs version, or adding/removing a version from the version selector.
Adding or modifying HTTP REST API endpoints in Golem services. Use when creating new endpoints, changing existing API routes, or updating request/response types for the Golem REST API.
Final checks before submitting a pull request. Use when preparing to create a PR, to ensure formatting, linting, and the correct tests have been run.
Adding a new component or agent templates to an existing Golem application. Use when adding a second component, adding agent templates like human-in-the-loop or snapshotting to an existing component, or converting a single-component app to multi-component.
Defining environment variables for Golem agents in `golem.yaml` (`env`, `envDefaults`, `secretDefaults`) or via CLI. Use when adding, setting, or overriding env vars on a component, agent, template, preset, or environment, or when wiring template substitution and merge modes.