Command Line Tools
Advanced Testing Commands
Advanced Testing Commands
Section titled “Advanced Testing Commands”The Wheels CLI provides advanced testing capabilities through integration with TestBox. These commands offer specialized test runners for different testing scenarios.
Available Commands
Section titled “Available Commands”test:all - Run All Tests
Section titled “test:all - Run All Tests”Runs all tests in your application using TestBox CLI.
wheels test:allOptions
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
--type | string | app | Type of tests to run: (app, core) |
--format | string | txt | Output format (txt, json, junit, html) |
--coverage | boolean | false | Generate coverage report |
--coverageReporter | string | - | Coverage reporter format (html, json, xml) |
--coverageOutputDir | string | - | Directory for coverage output |
--verbose | boolean | true | Display extra details including passing and skipped tests |
--directory | string | tests/specs | The directory to use to discover test bundles and specs to test. Mutually exclusive with bundles. Example: directory=tests.specs |
--recurse | boolean | true | Recurse the directory mapping or not |
--bundles | string | - | The path or list of paths of the spec bundle CFCs to run and test ONLY |
--labels | string | - | The list of labels that a suite or spec must have in order to execute |
--excludes | string | - | The list of labels that a suite or spec must not have in order to execute |
--filter | string | - | Test filter pattern |
Examples
Section titled “Examples”# Run all app testswheels test:all
# Run with JSON formatwheels test:all --format=json
# Run with coveragewheels test:all --coverage --coverageReporter=html
# Filter tests by namewheels test:all --filter=UserTest --verbose
# Run core testswheels test:all --type=core
# Run specific bundleswheels test:all --bundles=tests.specs.unit.models,tests.specs.unit.controllerstest:unit - Run Unit Tests
Section titled “test:unit - Run Unit Tests”Runs only unit tests located in the tests/specs/unit directory.
wheels test:unitOptions
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
--type | string | app | Type of tests to run: (app, core) |
--format | string | txt | Output format (txt, json, junit, html) |
--verbose | boolean | true | Display extra details including passing and skipped tests |
--bundles | string | - | The path or list of paths of the spec bundle CFCs to run and test ONLY |
--labels | string | - | The list of labels that a suite or spec must have in order to execute |
--excludes | string | - | The list of labels that a suite or spec must not have in order to execute |
--filter | string | - | Test filter pattern |
--directory | string | tests/specs/unit | The directory to use to discover test bundles and specs to test. Mutually exclusive with bundles. Example: directory=tests.specs |
Examples
Section titled “Examples”# Run unit testswheels test:unit
# Run with JSON formatwheels test:unit --format=json
# Filter specific testswheels test:unit --filter=UserModelTest
# Run core unit testswheels test:unit --type=coretest:integration - Run Integration Tests
Section titled “test:integration - Run Integration Tests”Runs only integration tests located in the tests/specs/integration directory.
wheels test:integrationOptions
Section titled “Options”Same as test:unit but defaults to tests/specs/integration directory.
Examples
Section titled “Examples”# Run integration testswheels test:integration
# Run specific workflow testswheels test:integration --filter=UserWorkflowTest
# With verbose output and JUnit formatwheels test:integration --verbose --format=junit
# Run integration testswheels test:integration --type=apptest:watch - Watch Mode
Section titled “test:watch - Watch Mode”Watches for file changes and automatically reruns tests.
wheels test:watchOptions
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
--type | string | app | Type of tests to run: (app, core) |
--directory | string | tests/specs | The directory to use to discover test bundles and specs to test. Mutually exclusive with bundles. Example: directory=tests.specs |
--format | string | txt | Output format (txt, json, junit, html) |
--verbose | boolean | true | Display extra details including passing and skipped tests |
--delay | integer | 1000 | Delay in milliseconds before rerunning tests |
--bundles | string | - | The path or list of paths of the spec bundle CFCs to run and test ONLY |
--labels | string | - | The list of labels that a suite or spec must have in order to execute |
--excludes | string | - | The list of labels that a suite or spec must not have in order to execute |
--filter | string | - | Test filter pattern |
Examples
Section titled “Examples”# Watch all testswheels test:watch
# Watch unit tests onlywheels test:watch --directory=tests/specs/unit
# Watch with custom delay and JSON formatwheels test:watch --delay=500 --format=jsontest:coverage - Code Coverage
Section titled “test:coverage - Code Coverage”Runs tests with code coverage analysis (requires FusionReactor).
wheels test:coverageOptions
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
--type | string | app | Type of tests to run: (app, core) |
--directory | string | tests/specs | The directory to use to discover test bundles and specs to test. Mutually exclusive with bundles. Example: directory=tests.specs |
--format | string | txt | Output format (txt, json, junit, html) |
--outputDir | string | tests/results/coverage | Directory to output the coverage report |
--threshold | integer | - | Coverage percentage threshold (0-100) |
--pathsToCapture | string | /app | Paths to capture for coverage |
--whitelist | string | *.cfc | Whitelist paths for coverage |
--blacklist | string | *Test.cfc,*Spec.cfc | Blacklist paths from coverage |
--bundles | string | - | The path or list of paths of the spec bundle CFCs to run and test ONLY |
--labels | string | - | The list of labels that a suite or spec must have in order to execute |
--excludes | string | - | The list of labels that a suite or spec must not have in order to execute |
--filter | string | - | Test filter pattern |
--verbose | boolean | true | Display extra details including passing and skipped tests |
Examples
Section titled “Examples”# Basic coveragewheels test:coverage
# With threshold and specific directorywheels test:coverage --threshold=80 --directory=tests/specs/unit
# Coverage for specific pathswheels test:coverage --pathsToCapture=/models,/controllers
# With JUnit outputwheels test:coverage --format=json --outputDir=coverage-reportsTest Organization
Section titled “Test Organization”Directory Structure
Section titled “Directory Structure”The standard test directory structure for Wheels applications:
tests/├── specs/ # Main test directory (default for type=app)│ ├── unit/ # Unit tests│ │ ├── models/ # Model unit tests│ │ ├── controllers/ # Controller unit tests│ │ └── helpers/ # Helper unit tests│ ├── integration/ # Integration tests│ │ ├── workflows/ # User workflow tests│ │ └── api/ # API integration tests│ └── functions/ # Function-specific tests└── results/ # Test results and reports └── coverage/ # Coverage reportsTest Types
Section titled “Test Types”The --type parameter determines which test suite to run:
- app (default): Runs tests in
/wheels/app/testsroute, usestests/specsdirectory - core: Runs tests in
/wheels/core/testsroute, for framework tests
Sample Tests
Section titled “Sample Tests”When you run test:unit or test:integration for the first time and the directories don’t exist, sample test files are created automatically in the correct locations:
- Unit tests:
tests/specs/unit/SampleUnitTest.cfc - Integration tests:
tests/specs/integration/SampleIntegrationTest.cfc
Output Formats
Section titled “Output Formats”All test commands support multiple output formats via the --format parameter:
- txt (default): Human-readable text output
- json: JSON format for parsing and automation
- junit: JUnit XML format for CI/CD integration
- html: HTML format for browser viewing
Best Practices
Section titled “Best Practices”-
Organize Tests by Type
- Keep unit tests in
tests/specs/unit/ - Keep integration tests in
tests/specs/integration/ - Use subdirectories for better organization
- Keep unit tests in
-
Use Labels for Test Organization
it("should process payments", function() {// test code}).labels("critical", "payments"); -
Set Coverage Thresholds
- Aim for at least 80% code coverage
- Use
--thresholdto enforce minimum coverage
-
Watch Mode for TDD
- Use
test:watchduring development - Keep tests running in a separate terminal
- Use
-
CI/CD Integration
- Use
--format=junitfor CI systems - Generate coverage reports with
--coverageReporter=xml
- Use
Coverage Requirements
Section titled “Coverage Requirements”Code coverage requires FusionReactor 8.0+ to be installed and configured:
- Install FusionReactor
- Enable Code Coverage in FusionReactor settings
- Restart your ColdFusion/Lucee server
- Run
wheels test:coverage
Troubleshooting
Section titled “Troubleshooting”TestBox CLI Not Found
Section titled “TestBox CLI Not Found”If you get an error about TestBox CLI not being installed:
box install testbox-clibox reloadNo Tests Found
Section titled “No Tests Found”Make sure your test files:
- Are in the correct directory (
tests/specs/or subdirectories) - Have the
.cfcextension - Extend
wheels.Testbox
Coverage Not Working
Section titled “Coverage Not Working”If coverage shows as disabled:
- Verify FusionReactor is installed
- Check that Code Coverage is enabled in FusionReactor settings
- Ensure you’ve restarted the server after enabling coverage
Test Routes Not Working
Section titled “Test Routes Not Working”The test commands use these routes:
- App tests:
http://localhost:port/wheels/app/tests - Core tests:
http://localhost:port/wheels/core/tests
Ensure these routes are accessible and properly configured.
Related Commands
Section titled “Related Commands”wheels test run- Modern test runner (not a TestBox wrapper)box testbox run- Direct TestBox CLI usagewheels g test- Generate test files