coldbox-testing-handlerlisted
Install: claude install-skill ColdBox/skills
# Handler Testing in ColdBox
## When to Use This Skill
- Writing tests for ColdBox handlers/controllers
- Asserting what view, layout, or data a handler returns
- Verifying redirect/relocation behavior after form submissions
- Testing RESTful handlers that call `renderData()`
- Checking HTTP status codes set by handlers
- Unit-testing a handler in full isolation with `BaseHandlerTest`
## Language Mode Reference
| Concept | BoxLang (`.bx`) preferred | CFML (`.cfc`) compatible |
|---|---|---|
| Class declaration | `class extends="..." {}` | `component extends="..." {}` |
| Closures | `() => {}` | `function() {}` |
---
## Testing Class Choices
| Class | Purpose |
|---|---|
| `coldbox.system.testing.BaseTestCase` | **Integration** — loads the full virtual ColdBox app |
| `coldbox.system.testing.BaseHandlerTest` | **Isolated unit** — tests the handler CFC with no app load |
Use `BaseTestCase` for most handler tests. Use `BaseHandlerTest` only when you want full isolation.
---
## Integration Handler Test (BaseTestCase)
```boxlang
class extends="coldbox.system.testing.BaseTestCase" appMapping="/root" {
function beforeAll() {
super.beforeAll()
}
function afterAll() {
super.afterAll()
}
function run() {
describe( "Main Handler", () => {
beforeEach( () => {
// CRITICAL: fresh virtual request per spec
setup()
} )
it( "renders the homepage", () => {