| description | TestBox is a next-generation testing framework based on BDD (Behavior Driven Development) and TDD (Test Driven Development), providing a clean, obvious syntax for writing tests. | ||
|---|---|---|---|
| icon | house-chimney-user | ||
| metaLinks |
|
TestBox is a modern testing framework for BoxLang and ColdFusion (CFML), built around behavior-driven development (BDD) and designed to make tests clear and expressive. It includes BDD and xUnit testing, console and web runners, assertion and expectation libraries, and MockBox for mocking and stubbing.
{% tabs %} {% tab title="BDD - BoxLang" %}
class{
function run(){
describe( "My calculator features", () => {
beforeEach( () => {
variables.calc = new Calculator()
} )
// Using expectations library
it( "can add", () => {
expect( calc.add(1,1) ).toBe( 2 )
} )
// Using assert library
test( "it can multiply", () => {
assertIsEqual( calc.multiply(2,2), 4 )
} )
} )
}
}{% endtab %}
{% tab title="xUnit - BoxLang" %}
/**
* My calculator features
*/
class{
property calc;
function setup(){
calc = new Calculator()
}
// Function name includes the word 'test'
// Using expectations library
function testAdd(){
expect( calc.add(1,1) ).toBe( 2 )
}
// Any name, but with a test annotation
// Using assertions library
@test
function itCanMultiply(){
$assert.isEqual( calc.multiply(2,2), 4 )
}
}{% endtab %}
{% tab title="BDD - CFML" %}
component{
function run(){
describe( "My calculator features", () => {
beforeEach( () => {
variables.calc = new Calculator()
} );
// Using expectations library
it( "can add", () => {
expect( calc.add(1,1) ).toBe( 2 )
} );
// Using assert library
test( "it can multiply", () => {
$assert.isEqual( calc.multiply(2,2), 4 )
} );
} );
}
}
{% endtab %}
{% tab title="xUnit - CFML" %}
/**
* My calculator features
*/
component{
property calc;
function setup(){
calc = new Calculator()
}
// Function name includes the word 'test'
// Using expectations library
function testAdd(){
expect( calc.add(1,1) ).toBe( 2 )
}
// Any name, but with a test annotation
// Using assertions library
function itCanMultiply() test{
$assert.isEqual( calc.multiply(2,2), 4 )
}
}
{% endtab %} {% endtabs %}
Runner
Drive a real browser (Chromium, Firefox or WebKit) right from your specs. Add the @browser annotation to a spec, call browse(), and assert on what your users actually see. Powered by bx-playwright on BoxLang.
{% hint style="info" %}
Browser testing requires BoxLang and the bx-playwright module. Write browser specs as BoxLang classes (.bx) and keep them out of Lucee and Adobe runs. On BoxLang without bx-playwright they skip with an install hint, so the rest of your suite still runs.
{% endhint %}
A browser spec signing in and checking the dashboard
{% code title="tests/specs/browser/ShopSpec.bx" %}
@baseURL( "http://localhost:8090" )
@browserProfile( "ci" )
class extends="testbox.system.BaseSpec" {
function run() {
describe( "Ortus Shop", () => {
it( "signs in and shows the dashboard", () => {
browse( ( page ) => {
page.visit( "/" )
.fill( "Email", "[email protected]" )
.fill( "Password", "secret" )
.click( "Sign in" )
expect( page ).toHavePath( "/dashboard.html" )
expect( page ).toSee( "Welcome, Luis" )
} )
} )
} )
}
}{% endcode %}
When a browser spec fails, TestBox captures the evidence for you: a screenshot of the page, a Playwright trace you can step through, and a video of the run, all linked right on the failing spec in your report.
Failure screenshot, trace and video attached to the failing spec
Step through the failure in the Playwright trace viewer
Then fix it and rerun only what failed with --failed or the Run Failed button. Start with the Browser Testing guide.
Here is a simple listing of features TestBox brings to the table:
- BDD style or xUnit style testing
- Testing life-cycle methods
- MockBox integration for mocking and stubbing
- Mocking data library for mocking JSON/complex data and relationships
- Ability to extend and create custom test runners and reporters
- Extensible reporters, bundled with tons of them:
- JSON
- XML
- JUnit XML
- Text
- Console
- TAP (Test Anything Protocol)
- Simple HTML
- Min - Minimalistic Heaven
- Raw
- CommandBox
- Browser testing with automatic failure screenshots, traces and videos
- Rerun only what failed, from the CLI (
--failed) or the web runners (Run Failed) - Asynchronous testing
- Multi-suite capabilities
- Test skipping
- Test labels and tagging
- Testing debug output stream
- Code Coverage via FusionReactor
- Much more!
TestBox is maintained under the Semantic Versioning guidelines as much as possible. Releases will be numbered in the following format:
<major>.<minor>.<patch>
And constructed with the following guidelines:
- bumpBreaking backward compatibility bumps the major (and resets the minor and patch)
- New additions without breaking backward compatibility bump the minor (and resets the patch)
- Bug fixes and misc changes bump the patch
TestBox is open source and licensed under the Apache 2 License. If you use it, please try to mention it in your code or website.
- Copyright by Ortus Solutions, Corp
- TestBox is a registered trademark by Ortus Solutions, Corp
{% hint style="info" %} The ColdBox Websites, Documentation, logo, and content have a separate license, and they are separate entities. {% endhint %}
- Help Group: https://community.ortussolutions.com/c/communities/testbox/11
- BoxTeam Slack : https://boxteam.ortussolutions.com
We all make mistakes from time to time :) So why not let us know about it and help us out? We also love pull requests, so please star us and fork us: https://github.com/Ortus-Solutions/TestBox
TestBox is a professional open source software backed by Ortus Solutions, Corp offering services like:
- Custom Development
- Professional Support & Mentoring
- Training
- Server Tuning
- Security Hardening
- Code Reviews
- Much More
- Official Site: https://www.ortussolutions.com/products/testbox
- Current API Docs: https://apidocs.ortussolutions.com/testbox/current
- Help Group: https://community.ortussolutions.com/c/communities/testbox/11
- Source Code: https://github.com/Ortus-Solutions/TestBox
- Bug Tracker: https://ortussolutions.atlassian.net/browse/TESTBOX
- Twitter: @ortussolutions
- Facebook: https://www.facebook.com/ortussolutions
Because of His grace, this project exists. If you don't like this, don't read it, it's not for you.
Therefore being justified by faith, we have peace with God through our Lord Jesus Christ: By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God. - Romans 5:5





.png)