Run TestBox tests for your application with advanced features.
Synopsis
wheelstestrun [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).
Options
Option
Description
Default
filter
Filter tests by pattern or name
group
Run specific test group
--coverage
Generate coverage report (boolean flag)
false
reporter
Test reporter format: console, junit, json, tap
console
--watch
Watch for file changes and rerun tests (boolean flag)
false
--verbose
Verbose output (boolean flag)
false
--fail-fast
Stop on first test failure (boolean flag)
false
Examples
Run all tests
wheels test run
Filter tests by pattern
wheels test run filter="User"
wheels test run filter="test_user_validation"
Watch mode
wheels test run --watch
Run specific test group
wheels test run group="unit"
wheels test run group="integration"
Generate coverage report
wheels test run --coverage
Use different reporter
wheels test run reporter=json
wheels test run reporter=junit
wheels test run reporter=tap
Stop on first failure
wheels test run --fail-fast
Verbose output with coverage
wheels test run --verbose --coverage reporter=console
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