Run TestBox tests for your application with advanced features.
Synopsis
wheels test run [spec] [options]
Description
The wheels test run command executes your application's TestBox test suite with support for watching, filtering, and various output formats. This is the primary command for running your application tests (as opposed to framework tests).
Arguments
Argument
Description
Default
spec
Specific test spec or directory
All tests
Options
Option
Description
Default
--watch
Watch for changes and rerun
false
--reporter
TestBox reporter
simple
--recurse
Recurse directories
true
--bundles
Test bundles to run
--labels
Filter by labels
--excludes
Patterns to exclude
--filter
Test name filter
--outputFile
Output results to file
--verbose
Verbose output
false
--help
Show help information
Examples
Run all tests
wheels test run
Run specific test file
wheels test run tests/models/UserTest.cfc
Run tests in directory
wheels test run tests/controllers/
Watch mode
wheels test run --watch
Run specific bundles
wheels test run --bundles=models,controllers
Filter by labels
wheels test run --labels=unit,critical
Use different reporter
wheels test run --reporter=json
wheels test run --reporter=junit
wheels test run --reporter=text
Save results to file
wheels test run --reporter=junit --outputFile=test-results.xml
function beforeAll() {
transaction action="begin";
}
function afterAll() {
transaction action="rollback";
}
Database Cleaner
function beforeEach() {
queryExecute("DELETE FROM users");
queryExecute("DELETE FROM products");
}
Fixtures
function loadFixtures() {
var users = deserializeJSON(
fileRead("/tests/fixtures/users.json")
);
for (var userData in users) {
model("User").create(userData);
}
}
CI/CD Integration
GitHub Actions
- name: Run tests
run: |
wheels test run --reporter=junit --outputFile=test-results.xml
- name: Upload results
uses: actions/upload-artifact@v2
with:
name: test-results
path: test-results.xml
Pre-commit Hook
#!/bin/bash
# .git/hooks/pre-commit
echo "Running tests..."
wheels test run --labels=unit
if [ $? -ne 0 ]; then
echo "Tests failed. Commit aborted."
exit 1
fi
Performance Tips
Use labels for fast feedback
wheels test run --labels=unit # Fast
wheels test run --labels=integration # Slow
Parallel execution
wheels test run --threads=4
Watch specific directories
wheels test run tests/models --watch
Skip slow tests during development
wheels test run --excludes="*integration*"
Common Issues
Out of Memory
# Increase memory
box server set jvm.heapSize=1024
box server restart