Overview

A quick overview of TestBox

TestBox is a next-generation testing framework for the BoxLang JVM language and ColdFusion (CFML) language based on BDD (Behavior Driven Development) for providing a clean, obvious syntax for writing tests. It contains not only a testing framework, console/web runner, assertions, and expectations library but also ships with several mocking utilities.

Styles

In TestBox you can write your tests in two different styles or approaches.

BDD (Behavior Driven Development)

BDD stands for behavior-driven development and is highly based on creating specifications and expectations of results in a readable DSL (Domain Specific Language). You are not focusing on a specific unit and method to test, but on functionality, features and more. This can encompass not only unit but also integration testing.

xUnit (Test Driven Development)

xUnit style of testing is the more traditional TDD or test-driven development approach where you create a test case bundle class that matches the software under test, and for each method in the SUT, you create a test method in the test bundle class.

Assertions & Expectations

We also give you two ways to do assertions:

  1. Assertions library, which is a traditional approach to assertions

  2. Expectations library, which is a more fluent approach to assertions.

Life-Cycles

Both approaches also offer different life-cycle callbacks so you can execute code during different times in the test execution.

Utilities

TestBox will also offer different utilities:

  • Debug output to a debug buffer

  • Mock classes, methods and properties

  • Extension data mocking and JSON mocking

  • Logging facilities

Runners

You can also execute your tests via the CLI, IDE or the web server.

Reports

TestBox can produce many different types of reports for your test executions:

  • CLI / Console Output

  • VSCode Output

  • JSON

  • XML

  • JUNIT

  • TAP

  • HTML

  • DOC

  • Your own

Here is a few samples:

describe( "My calculator features", () => {

	beforeEach( () => {
		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 )
	} )
} )

Useful Resources

Last updated