coldbox-testing-interceptor

Unit test ColdBox interceptors in isolation using BaseInterceptorTest and pre-wired mocks.

1|Updated Apr 10, 2026
One-click install
npx skills add https://github.com/ColdBox/skills --skill coldbox-testing-interceptor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: coldbox-testing-interceptor
Source: https://github.com/ColdBox/skills/tree/main/coldbox/testing-interceptor
Command: npx skills add https://github.com/ColdBox/skills --skill coldbox-testing-interceptor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a concise, repeatable approach for unit testing ColdBox interceptor CFCs in complete isolation without booting a full ColdBox application, reducing test flakiness and setup overhead.

Core Features & Use Cases

  • Pre-wired mocks: Supplies ready-to-use mockController, mockRequestService, mockLogger, mockLogBox, and mockFlash for rapid test development.
  • Direct interception testing: Call interception points (preProcess, postProcess, onException, custom announce points) directly on the interceptor instance to assert behavior and side effects.
  • Configurable interceptor properties: Set configProperties before super.setup() and inject mock collaborators via prepareMock or property injection to simulate dependencies.
  • Scaffolding support: Use provided CommandBox generators to scaffold interceptors and their unit tests quickly.

Quick Start

Create a unit test that extends BaseInterceptorTest, set configProperties before setup, inject any required mocks, invoke the desired interception point on variables.interceptor with a mocked request context, and assert interactions on the mocks.

Frequently Asked Questions about coldbox-testing-interceptor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I unit test a ColdBox interceptor in isolation without booting the full application?

To unit test ColdBox interceptors in isolation, extend BaseInterceptorTest to access pre-wired mock helpers like mockController and mockRequestService, avoiding a full application boot. You then call interception points directly on the interceptor instance with a mocked request context.

How do I mock the request context and logger when testing interception points?

Mock the request context and logger using the pre-wired mockRequestService, mockLogger, and mockLogBox helpers provided by the BaseInterceptorTest harness. You pass the mocked request context directly when invoking interception points.

How do I set configProperties before running setup in my interceptor tests?

Set configProperties before calling super.setup() in your unit test's setup method. This ensures the interceptor initializes with the correct configuration properties before you inject any additional mock collaborators.

Can I test custom announce points and onException handlers directly on the interceptor instance?

Yes, you can call custom announce points and onException handlers directly on variables.interceptor with a mocked request context. This direct invocation lets you assert specific behavior and side effects for each interception point.

What is the best way to inject mock collaborators into a ColdBox interceptor during testing?

The best way to inject mock collaborators is via prepareMock or property injection after setting configProperties. This allows you to simulate dependencies like the controller, request service, logger, and flash scope before asserting interactions.

Does TestBox work with the BaseInterceptorTest harness for mocking controller and flash scope?

Yes, TestBox works seamlessly with the BaseInterceptorTest harness, which supplies ready-to-use mockController and mockFlash objects. These pre-wired mocks reduce setup overhead and flakiness when testing ColdBox interceptors.