← ClaudeAtlas

coldbox-testing-handlerlisted

Use this skill when testing ColdBox event handlers with execute(), asserting rc/prc collections, verifying view selection and rendered output, mocking relocations, testing renderData() and getHandlerResults(), setting HTTP methods and headers, injecting mocks into handlers, or using BaseHandlerTest for isolated handler unit tests.
ColdBox/skills · ★ 0 · Testing & QA · score 61
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", () => {