square-terminalTestBox CLI

The official TestBox CLI for CommandBox — run, scaffold, watch, and manage your tests from the command line.

The TestBox CLI is a CommandBoxarrow-up-right module that brings test execution, scaffolding, watching, and project management directly to your terminal. It is the recommended way to interact with TestBox from the command line — especially for BoxLang projects.

System Requirements

  • CommandBox 6.x+

Installation

box install testbox-cli

Once installed, all testbox commands are available in your CommandBox shell. Use --help on any command to explore its options:

testbox run --help
testbox create bdd --help
testbox generate harness --help

🔍 Language Detection

The CLI automatically detects whether your project targets BoxLang 🟦 (primary) or CFML so that generated files use the correct syntax. Detection is applied in this order:

BoxLang Detection

  1. The server running in the current directory is a BoxLang server

  2. box.json contains testbox.runner=boxlang

  3. box.json contains language=boxlang

CFML Detection (fallback)

  1. The server running in the current directory is a CFML server (Lucee or Adobe ColdFusion)

  2. box.json contains language=cfml

You can always override detection for any generator command using --boxlang or --noBoxlang.


▶️ Running Tests

The testbox run command executes your TestBox suite via HTTP and renders formatted results in the CLI.

Basic Usage

Named Runners

Define multiple named runner targets in box.json for different environments:

Then target a specific runner by name:

Filtering Tests

Verbose Output

By default only failing test details are shown. Use --verbose to include passing and skipped specs:

Ad-hoc URL Options

Pass arbitrary URL parameters to the runner, either inline or persisted in box.json:

Output Formats for CI/CD

Produce multiple report formats from a single test run — all derived from the same JSON result:

Available formats: json, xml, junit, antjunit, simple, dot, doc, min, mintext, text, tap, codexwiki

🌊 Streaming Mode

Stream each spec result in real-time via Server-Sent Events (SSE) — no waiting for the full suite to finish:

circle-info

Streaming requires your TestBox runner to support SSE output. This is available natively when running TestBox on BoxLang or a compatible CFML server.

Configuring Defaults in box.json

Store your preferences in box.json so they apply automatically on every run:


👀 Watching Tests

The testbox watch command monitors your source files and automatically re-runs your tests whenever a file changes — great for a tight red/green/refactor loop.

Basic Usage

On each detected change the screen clears and testbox run fires with your configured options. Press Ctrl+C to stop the watcher.

Watch Options

Configuring the Watcher in box.json

circle-exclamation

🏗️ Scaffolding

The testbox create commands scaffold new test files in either BoxLang or CFML based on your project's language detection.

Create a BDD Spec

Generated BoxLang BDD Spec (MySpec.bx):

Create an xUnit Test

Generated BoxLang xUnit Test (MyTest.bx):


🧪 Generating a Test Harness

The testbox generate harness command scaffolds a complete tests/ directory for your project, including a runner, Application.bx/Application.cfc, and a sample spec — everything you need to start testing immediately.

circle-info

If TestBox is not already installed locally, the CLI will install it automatically before scaffolding the harness.


🌐 Generating a Test Browser

The testbox generate browser command creates a web-based test browser UI at tests/browser/ — a convenient, visual way to browse and execute your test bundles from a browser.

The browser UI is placed at tests/browser/ and can be accessed via your web server once your server is running.


📊 Generating a Test Visualizer

The testbox generate visualizer command generates a standalone HTML-based test results visualizer at tests/test-visualizer/. Load a JSON results file to get a rich visual breakdown of any test run.

Using the visualizer:

  1. Run your tests with JSON output: testbox run outputFormats=json outputFile=test-results

  2. Open tests/test-visualizer/index.html in your browser

  3. Load the generated test-results.json file


📦 Generating a TestBox Module

The testbox generate module command scaffolds a new TestBox extension module — ideal for packaging custom matchers, reporters, or shared test helpers.


🔧 Installation Management

View TestBox Info

Display which TestBox installation the CLI is currently using — local project copy or the CLI-bundled copy:

The output shows the active version, the path on disk, and its source. If no TestBox is found anywhere, you will be prompted to install it.

Reinstall the CLI Bundle

The CLI ships with its own bundled copy of TestBox used for output formatting and report generation. If this copy is outdated or corrupted, reinstall it:

circle-exclamation

📚 Documentation & Resources

Open the TestBox docs or API reference directly from the CLI:


⚡ Quick Reference

Command
Description

testbox run

Execute tests via HTTP runner

testbox run --streaming

Stream test results in real-time via SSE

testbox watch

Watch files and re-run tests on change

testbox create bdd <name>

Scaffold a new BDD spec

testbox create unit <name>

Scaffold a new xUnit test

testbox generate harness

Generate a full tests/ harness

testbox generate browser

Generate a web-based test browser UI

testbox generate visualizer

Generate an HTML test results visualizer

testbox generate module <name>

Scaffold a new TestBox extension module

testbox info

Show TestBox installation details

testbox reinstall

Reinstall the CLI-bundled TestBox

testbox docs

Open TestBox documentation in a browser

testbox apidocs

Open TestBox API docs in a browser

Last updated

Was this helpful?