boxlang-testinglisted
Install: claude install-skill ortus-boxlang/skills
# BoxLang Testing with TestBox
## Overview
TestBox is the standard testing framework for BoxLang. It supports two styles:
- **BDD** (Behavior-Driven Development) — `describe()`, `it()`, `feature()`, `story()`, `given()/when()/then()`
- **xUnit** — class-based, `test*()` methods, `setup()`/`tearDown()`
Both styles use the same assertions/expectations library and MockBox for mocking.
---
## Test Bundles
A test bundle is a BoxLang class (`.bx` file) that contains your tests. Name files
with `Test` or `Spec` suffix by convention: `UserServiceSpec.bx`, `OrderServiceTest.bx`.
```boxlang
// tests/specs/UserServiceSpec.bx
class extends="testbox.system.BaseSpec" {
function run() {
describe( "UserService", () => {
it( "can greet a user", () => {
expect( "hello" ).toBe( "hello" )
} )
} )
}
}
```
Extending `testbox.system.BaseSpec` is optional but recommended: it enables IDE
introspection, direct web runner execution, and faster test loading.
### Injected Variables (always available in bundles)
| Variable | Purpose |
|---|---|
| `$mockbox` | MockBox instance for creating mocks |
| `$assert` | Assertions library |
| `$utility` | Utility helpers |
| `$customMatchers` | Custom matcher registry |
| `$testID` | Unique ID for the bundle |
| `$debugBuffer` | Debug output buffer |
---
## BDD Style
### Basic Structure
```boxlang
class extends="testbox.system.BaseSpec" {
function run() {
describe( "Calcu