Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
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.
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 )
} )
} )
}
}

March 31, 2025
/**
* 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 )
}
}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 )
} );
} );
}
}/**
* 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 )
}
}<major>.<minor>.<patch>/testbox/run.bat - Windows runner
September 27, 2024
runnerbox.jsonboxlang
class extends="testbox.system.BaseSpec"{
function run(){
describe( "My First Test", ()=>{
test( "it can add", ()=>{
expect( sum( 1, 2 ) ).toBe( 3 )
} )
} )
}
private function sum( a, b ){
return a + b
}
}{
"name":"MyBoxLang Project",
"version":"1.0.0",
"language" : "boxlang" // or CFML or JAVA
}testbox create bdd MyTest --boxlang
testbox generate harness --boxlang./testbox/bin/run
./testbox/bin/run my.bundle
./testbox/bin/run --directory=tests.specs
./testbox/bin/run --bundles=my.bundle./testbox/bin/run.bat
./testbox/bin/run.bat my.bundle
./testbox/bin/run.bat --directory=tests.specs
./testbox/bin/run.bat --bundles=my.bundle// CommandBox
install bx-web-support
// BoxLang OS Binary
install-bx-module bx-web-supportdescribe("User Authentication", () => {
test("should successfully login with valid credentials", () => {
var user = authenticate("validUser", "validPassword");
expect( user.isAuthenticated() ).toBe(true);
});
test("should fail login with invalid credentials", () => {
var user = authenticate("invalidUser", "invalidPassword");
expect( user.isAuthenticated() ).toBe(false);
});
});// Before
function testAddition(){
assert( calc.add(2,3) == 5 )
}
function testMultiply(){
assert( calc.multiply(2,3) == 6 )
}
// After
@DisplayName "My calculator can add"
function testAddition(){
assert( calc.add(2,3) == 5 )
}
@DisplayName "My calculator can multiply"
function testMultiply(){
assert( calc.multiply(2,3) == 6 )
}// Before
function testAddition(){
assert( calc.add(2,3) == 5 )
}
function testMultiply(){
assert( calc.multiply(2,3) == 6 )
}
// After
function testAddition() DisplayName="My calculator can add"{
assert( calc.add(2,3) == 5 )
}
function testMultiply() DisplayName="My calculator can multiply"{
assert( calc.multiply(2,3) == 6 )
}$assert.isTrue()
$assert.isFalse()
$assert.isEqual()
$assert.isNotEqual()
$assert.null()assertIsTrue()
assertIsFalse()
assertIsEqual()
assertIsNotEqual()
assertNull()




