A brief history of TestBox
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 )
} )
} )
}
}/**
* 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>
Learn about the authors of TestBox and how to support the project.
July 28, 2023
TagContext has length on simple reportervoid function doSomething(foo){
// some code here then...
local.foo = variables.collaborator.callMe(local.foo);
variables.collaborator.whatever(local.foo);
}function test_it(){
local.mocked = createMock( "com.foo. collaborator" )
.$spy( "callMe" )
.$spy( "whatever" );
variables.CUT.$property( "collaborator", "variables", local.mocked );
assertEquals( 1, local.mocked.$count( "callMe" ) );
assertEquals( 1, local.mocked.$count( "whatever" ) );
}it( "can do something", () => {
...
if( condition ){
skip( "Condition is true, skipping spec" )
}
...
} )






