CLI Execution
Run a shell command inside a service container and capture the exit code, stdout, and stderr. Use this when you need to test CLI tools, scripts, or any operation that isn't an HTTP endpoint.
execution:
executor: cli
cli:
service: app
command: bin/console migrations:migrate --no-interaction
workingDir: /srv
Fields
| Field | Required | Description |
|---|---|---|
executor | yes | Must be cli |
cli.service | yes | Which service container to execute in |
cli.command | yes | Shell command (passed to sh -c) |
cli.workingDir | no | Working directory inside the container |
Available assertions
CLI tests give you access to three output channels:
exitCode— check the command exit code (0 = success)stdout— check what the command printed to standard outputstderr— check what the command printed to standard errorsnapshot— compare stdout or stderr against a saved file
Full example
- name: Migration runs successfully
services:
- name: app
image: myapp:latest
healthcheck:
test: "curl -f http://localhost:8080/health"
retries: 30
execution:
executor: cli
cli:
service: app
command: bin/console migrations:migrate --no-interaction
workingDir: /srv
assertions:
- exitCode:
equals: 0
- stdout:
contains: "migrated successfully"