TestBox CLI
The official TestBox CLI for CommandBox โ run, scaffold, watch, and manage your tests from the command line.
The TestBox CLI is a CommandBox 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-cliOnce 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
The server running in the current directory is a BoxLang server
box.jsoncontainstestbox.runner=boxlangbox.jsoncontainslanguage=boxlang
CFML Detection (fallback)
The server running in the current directory is a CFML server (Lucee or Adobe ColdFusion)
box.jsoncontainslanguage=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:
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
Make sure your server is already running and testbox.runner is configured in box.json before starting the watcher.
๐๏ธ 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.
๐ 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:
Run your tests with JSON output:
testbox run outputFormats=json outputFile=test-resultsOpen
tests/test-visualizer/index.htmlin your browserLoad the generated
test-results.jsonfile
๐ฆ 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:
testbox reinstall only affects the CLI-bundled copy of TestBox. It does not touch any TestBox installation inside your project.
๐ Documentation & Resources
Open the TestBox docs or API reference directly from the CLI:
โก Quick Reference
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?