testbox-unit-xunit

Write xUnit-style TestBox unit tests for ColdBox services, models, and utilities.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide clear patterns and conventions for writing deterministic, maintainable xUnit-style unit tests in TestBox so developers can validate CFC services, models, and utilities in isolation without fragile setup or inconsistent assertions.

Core Features & Use Cases

  • Lifecycle guidance for global and per-test setup and teardown using beforeTests, afterTests, setup, and teardown to manage shared resources and ensure test isolation.
  • Assertion and matcher usage with the $assert API and BoxLang dynamic assertion helpers, plus mixing fluent expect() matchers when desired.
  • Mocking and Arrange-Act-Assert examples for unit-testing service logic, verifying interactions, skipping conditional tests, and registering custom reusable assertions.

Quick Start

Create an xUnit TestBox spec that uses beforeTests to initialize shared fixtures, setup/teardown to prepare per-test state, and testXxx functions that assert behavior with $assert.

Frequently Asked Questions about testbox-unit-xunit

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

FAQPage Schema
How do I write xUnit unit tests for ColdBox services and models using TestBox?

To write xUnit unit tests for TestBox, create test bundles using beforeTests and afterTests for global setup, setup and teardown for per-test state, and testXxx functions that assert behavior with $assert, following the Arrange-Act-Assert pattern.

What is the difference between beforeTests and setup lifecycle hooks in TestBox xUnit bundles?

In TestBox xUnit bundles, beforeTests runs once globally before all tests for shared fixture initialization, while setup runs before each individual test to prepare isolated per-test state, with teardown and afterTests handling respective cleanup.

Can I mix BDD fluent expect() matchers with xUnit $assert assertions in TestBox?

Yes, you can mix xUnit $assert API assertions with BDD fluent expect() matchers in TestBox, leveraging BoxLang dynamic assertion helpers and registering custom reusable assertions within the same test bundle.

Does TestBox xUnit support mocking and test skipping for BoxLang and CFML projects?

TestBox xUnit supports mocking for verifying service interactions and conditional test skipping, satisfying requirements for both BoxLang and CFML compatibility when unit-testing models and utilities.

How do I structure Arrange-Act-Assert patterns in TestBox xUnit test functions?

Structure Arrange-Act-Assert in TestBox xUnit by initializing fixtures and mocks in the arrange phase, executing service logic in the act phase, and validating behavior using $assert assertions in the assert phase.