Skip to content
super simple cli testing
Branch: master
Clone or download
Latest commit 851214b Apr 11, 2019

Build Status GoDoc Go Report Card Maintainability Test Coverage Github All Releases


Define language independent tests for your command line scripts and programs in simple yaml files.

  • It runs on windows, osx and linux
  • It is a self-contained binary - no need to install a heavy lib or language
  • It is easy and fast to write

For more information take a look at the manual, the examples or the integration tests.


Linux & osx

Visit the release page to get the binary for you system.

curl -L -o commander
chmod +x commander


  • Download the current release
  • Add the path to your path environment variable
  • Test it: commander --version

Quick start

Commander will always search for a default commander.yaml in the current working directory and execute all defined tests in it.

# You can even let commander add tests for you!
$ ./commander test examples/commander.yaml
  echo hello:
    exit-code: 0
    stdout: hello

written to /tmp/commander.yaml

# ... and execute!
$ ./commander test
Starting test file commander.yaml...

✓ echo hello

Duration: 0.002s
Count: 1, Failed: 0

Complete YAML file

Here you can see an example with all features.

config: # Config for all executed tests
    dir: /tmp #Set working directory
    env: # Environment variables
        KEY: global
    timeout: 50s # Define a timeout for a command under test
    retries: 2 # Define retries for each test
    echo hello: # Define command as title
        stdout: hello # Default is to check if it contains the given characters
        exit-code: 0 # Assert exit-code
    it should fail:
        command: invalid
                - invalid # Assert only contain work
                - not in there # Validate that a string does not occur in stdout
            exactly: "/bin/sh: 1: invalid: not found"
            line-count: 1 # Assert amount of lines
            lines: # Assert specific lines
                1: "/bin/sh: 1: invalid: not found"
        exit-code: 127
    it has configs:
        command: echo hello
                - hello #See test "it should fail"
            exactly: hello
            line-count: 1
            dir: /home/user # Overwrite working dir
                KEY: local # Overwrite env variable
                ANOTHER: yeah # Add another env variable
            timeout: 1s # Overwrite timeout
            retries: 5
        exit-code: 0


# Execute file commander.yaml in current directory
$ ./commander test 

# Execute a specific suite
$ ./commander test /tmp/test.yaml

# Execute a single test
$ ./commander test /tmp/test.yaml "my test"

Adding tests

You can use the add argument if you want to commander to create your tests.

# Add a test to the default commander.yaml
$ ./commander add echo hello
written to /tmp/commander.yaml

# Write to a given file
$ ./commander add --file=test.yaml echo hello
written to test.yaml

# Write to stdout and file
$ ./commander add --stdout echo hello
  echo hello:
    exit-code: 0
    stdout: hello

written to /tmp/commander.yaml

# Only to stdout
$ ./commander add --stdout --no-file echo hello
  echo hello:
    exit-code: 0
    stdout: hello


   Commander - CLI app testing

   commander [global options] command [command options] [arguments...]

     test     Execute the test suite
     add      Automatically add a test to your test suite
     help, h  Shows a list of commands or help for one command

   --help, -h     show help
   --version, -v  print the version


# Initialise dev environment
$ make init

# Build the project binary
$ make build

# Unit tests
$ make test

# Coverage
$ make test-coverage

# Integration tests
$ make integration

# Add depdencies to vendor
$ make deps


Heavily inspired by goss.

Similar projects:

You can’t perform that action at this time.