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

FieldRequiredDescription
executoryesMust be cli
cli.serviceyesWhich service container to execute in
cli.commandyesShell command (passed to sh -c)
cli.workingDirnoWorking 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 output
  • stderr — check what the command printed to standard error
  • snapshot — 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"