dmx
Configuration

Test Commands

Choose what the Dev and Validate loops run as tests, in a single-service repository or for each service in a monorepo.

The Dev and Validate loops end with a test gate: the run_tests validator runs your tests, and the loop moves on only when they pass. This page explains which command that gate runs, and how to change it, for example to run integration tests as well as unit tests.

Where the command comes from

The gate runs a command, not a list of test files, and dmx gets that command from one of three places:

RepositoryCommand
Without componentstest_command in .dmx/config.md when it's set; otherwise the one dmx detects
With components, a change inside a componentThat component's test in its component.yaml, or the one dmx works out for its folder. See Monorepo tests
With components, a change outside every componenttest_command in .dmx/config.md; otherwise every component's tests

Detection looks at the repository's root:

  • pyproject.toml with a uv.lock → uv run pytest -q
  • pyproject.toml without one → pytest -q
  • package.json with a test script → npm test --silent
  • Makefile with a test: target → make test
  • go.mod → go test ./...

The first match wins. When nothing matches and no test_command is set, the gate fails and says to set one.

Put simply, test_command is the command for changes no component owns. A repository without components has no components, so it covers every change.

Setting a command

In a repository without components, add test_command to .dmx/config.md:

test_command: go test ./... && go test -tags integration ./...

For a service in a monorepo, set test in its component.yaml:

test:
  cmd: go test ./... && go test -tags integration ./...
  cwd: services/payments

Both run through sh -c, so you can join steps with &&: each step runs only if the one before it passed. test_command runs from the repository's root. A component's test runs from cwd, which is relative to the root and defaults to it, so set it to the component's folder when the command expects to run there.

On Windows, both need the sh from Git for Windows.

Then run dmx check. Its Runs line shows the command the next gate will run, and says when it comes from test_command.

Running more than one kind of test

A common reason to set a command is a second kind of test that the detected command doesn't run: integration tests, tests behind a marker, or tests that need a service running first.

Go. Integration tests are often behind a build tag:

test_command: go test ./... && go test -tags integration ./...

go test -tags integration ./... also runs the untagged unit tests, because the tag adds files and takes none away. Running go test ./... first means a unit test failure stops the gate before the slower integration run. If running the unit tests twice costs too much time, use the second command on its own.

Python. With a pytest marker:

test_command: uv run pytest -q -m "not integration" && uv run pytest -q -m integration

Node. With a separate script:

test_command: npm test --silent && npm run test:integration --silent

Tests that need services. Start or check them as the first step. Make that step safe to repeat: start the services only when they aren't already running.

test_command: ./scripts/test-services.sh up && go test ./... && go test -tags integration ./...

When the steps get long, or several services share them, put them in a script and call it: test_command: ./scripts/test-all.sh. The script's exit code decides the gate.

Copy what CI does. If the CI job that runs these tests sets environment variables or flags, put them in the command too (CI=true go test ./...), so the gate and CI agree. /dmx/init reads your CI workflow and offers a test_command when CI runs more than the detected command.

What the gate reports

The gate reports one check, tests_pass. When the command fails, the pause message shows the end of its output, and the lines that name failing tests (pytest's FAILED and ERROR, Jest's FAIL, Go's --- FAIL:) become the rework tasks. A test that fails on the integration branch too, or only on some machines, goes in test_known_failures rather than being taken out of the command, so it keeps running and stays visible:

test_known_failures: [TestFlakyNetwork]

For Go, list a subtest by its full name (TestSchemaEvents/user-defined-function); that covers its parent's failure too. See Tests that fail for other reasons for how entries match.

In a monorepo

Two things to know about test_command in a repository with components:

  • It isn't a monorepo-wide override. It runs only for changes outside every component, such as go.work, a lock file or CI configuration. To change what a service runs, set test in its component.yaml.
  • On those changes, it replaces running every component's tests. Without test_command, a repo-wide change runs every component's tests, including each service's integration tests. With a test_command that runs only unit tests, it doesn't. If repo-wide changes should still run everything, leave test_command unset, or make it run everything.

On this page