---
title: TestBox from the CLI
summary: Install the TestBox CLI, run your suite, watch for changes, and pick output formats.
icon: phosphor-duotone:flask
tags: [course]
---

TestBox is the BDD and TDD testing framework. In this lesson you will install the CLI module and run your tests from the terminal.

## Install

```bash
box install testbox-cli
```

Then list what it adds:

```bash
box testbox help
```

## Run your tests

`testbox run` hits your test runner URL and prints a CLI formatted report. Your application server must be running, though it does not have to be a CommandBox server.

```bash
box testbox run "http://localhost:8080/tests/runner.cfm"
```

If you do not pass a URL, the default is `/tests/runner.cfm`. To change it once, store it in your `box.json`:

```bash
box package set testbox.runner="/tests/runner.cfm"
box testbox run
```

A relative path makes CommandBox take the host and port from your server settings.

!!! note "Exit codes"
    If any test fails, `testbox run` returns a failing exit code. That is what lets CI fail a build on a red test.

## Output formats

Ask for several report formats at once and write them to a file:

```bash
box testbox run outputformats=json,antjunit,simple
box testbox run outputformats=json,antjunit,simple outputFile=myresults
```

## Watch mode

`testbox watch` reruns the suite whenever a file changes. It needs your server running and the runner configured.

```bash
box testbox watch
box testbox watch **.cfc
```

Tune it from `box.json`:

```bash
box package set testbox.watchDelay=1000
box package set testbox.watchPaths=/models/**.cfc
```

Press `Ctrl+C` to stop.

## More options

Settings such as `verbose`, `labels` and `testSuites` can live in `box.json` under `testbox`, or be passed on the command. For the full list for your version, ask the command itself:

```bash
box testbox run help
```

## Recap

- `box install testbox-cli` adds the `testbox` namespace.
- `testbox run` prints results and fails with a non-zero exit code on failures.
- `testbox watch` reruns on change, and `outputformats` produces reports for other tools.
