giuseppe-trisciuoglio avatar

Unit Test Application Events

Unit test patterns for Spring events that mock publishers and call listeners directly without a booted context.

CCM score
51 of 100
skills.sh installs
3.9K
GitHub stars
372
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers publisher verification with ArgumentCaptor, direct @EventListener invocation, and @Async listener checks using JUnit 5 and Mockito
  • Includes Maven and Gradle dependency blocks plus worked examples for publishing, listener side effects, exception handling, and async handling
  • Enforces isolation by mocking ApplicationEventPublisher and warns against order-dependent tests and Thread.sleep() in CI
  • Designed for Spring Boot services where event listeners and publishers need fast unit-level coverage

Install

$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-application-events -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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 @EventListener method invocation and side effects
  • Testing event propagation through multiple listeners
  • Validating async event handling (@Async + @EventListener)
  • Mocking ApplicationEventPublisher in service tests

Instructions

Details

Repository
github.com/giuseppe-trisciuoglio/developer-kit
Categories
Testing & QA, Java & JVM
First seen
May 16, 2026

More from giuseppe-trisciuoglio/developer-kit

All 95

Similar to Unit Test Application Events

More Testing & QA