What problem does it solve?
Writing robust tests for CQRS command and query handlers can be verbose and error-prone. This Skill guides you through unit tests using mocked buses, integration tests with authorization and validation, and event-emission checks to ensure handlers behave correctly.
Core Features & Use Cases
- Unit Testing Command Handlers: set up a mock ApplicationContext and verify command handling logic in isolation.
- Testing Query Handlers: validate query resolution and result translation with minimal dependencies.
- Mocking the Command Bus & Context Propagation: simulate bus interactions and ExecutionContext to exercise the full pipeline safely.
- Authorization & Validation Tests: ensure security and data integrity before business logic executes.
- Event Emission & EDA Tests: verify domain events are published when handlers succeed or are suppressed when not annotated.
- ExecutionContext Tests: exercise user/tenant context propagation, feature flags, and properties.
Quick Start
Create a unit test class for a CQRS handler and start by mocking the CommandBus and wiring a sample handler to verify basic command and event flows.