
Unit Test Application Events
This one walks you through unit testing Spring application events without spinning up the whole context. You'll mock ApplicationEventPublisher, capture events with ArgumentCaptor to inspect payloads, and test listeners in isolation against mocked dependencies. It covers the async handler case too, complete with the Thread.sleep versus Awaitility tradeoff. The validation checkpoints are practical: confirm your captor actually caught something before asserting on fields, verify the right event type was published if listeners don't fire. Honestly, the error handling examples alone make this worth using. Most teams skip testing that listeners swallow exceptions gracefully, then wonder why one bad listener tanks the whole event chain in production.
- skills.sh installs
- 3.8K
- GitHub stars
- 369
- last updated
- Aug 21, 2026
Install
$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-application-events --agent claude-codeInstalls into .claude/skills of the current project.
Files
Unit Testing Application Events
Overview
Provides actionable patterns for testing Spring ApplicationEvent publishers and @EventListener consumers using JUnit 5 and Mockito — without booting the full Spring context.
When to Use
- Writing unit tests for event publishers or listeners
- Verifying that an event was published with correct payload
- Testing
@EventListenermethod invocation and side effects - Testing event propagation through multiple listeners
- Validating async event handling (
@Async+@EventListener) - Mocking
ApplicationEventPublisherin service tests
Instructions
Sponsors
Details
- Repository
- github.com/giuseppe-trisciuoglio/developer-kit
- Categories
- Testing & QA, Documentation, Java & JVM
- First seen
- May 16, 2026
More from giuseppe-trisciuoglio/developer-kit
All 102- Langchain4j Vector Stores Configuration3.8K
- Langchain4j Mcp Server Patterns3.8K
- Aws Sdk Java V2 S33.8K
- Langchain4j Testing Strategies3.8K
- Aws Sdk Java V2 Dynamodb3.8K
- Aws Rds Spring Boot Integration3.8K
- Nextjs Deployment3.8K
- Aws Sdk Java V2 Lambda3.8K
- Aws Sdk Java V2 Core3.8K
- Aws Sdk Java V2 Bedrock3.8K
- Aws Sdk Java V2 Messaging3.8K
- Aws Sdk Java V2 Secrets Manager3.8K
- Aws Sdk Java V2 Kms3.8K
- Aws Sdk Java V2 Rds3.8K
- Nestjs Drizzle Crud Generator3.8K
- Aws Lambda Python Integration3.8K
- Aws Lambda Typescript Integration3.7K
- Sonarqube Mcp3.7K
- Better Auth3.7K
- Aws Lambda Java Integration3.7K
- Aws Lambda Php Integration3.7K
- Spring Boot Project Creator3.7K
- Docs Updater3.7K
- Notebooklm3.7K