New advertisers: 50% off your first month with code FIRSTMONTHSee slots
giuseppe-trisciuoglio avatar

Unit Test Bean Validation

Patterns for unit testing Jakarta Bean Validation constraints and custom validators without Spring context.

skills.sh installs
5.1K
GitHub stars
372
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers built-in constraints (@NotNull, @Email, @Min, @Max, @Size), custom @Constraint implementations, cross-field checks, and validation groups
  • Includes a base test class that builds a shared Validator once, plus assertions on property paths, messages, and violation counts
  • Enforces testing both valid and invalid inputs, with edge cases like null, blank, and boundary values, and stateless custom validators
  • Designed for Hibernate Validator unit tests on DTOs and request objects, run in JUnit 5 without Spring Boot

Install

$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-bean-validation -y

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

Files

Unit Testing Jakarta Bean Validation

Overview

This skill provides executable patterns for unit testing Jakarta Bean Validation annotations and custom validators using JUnit 5. Covers built-in constraints (@NotNull, @Email, @Min, @Max, @Size), custom @Constraint implementations, cross-field validation, and validation groups. Tests run in isolation without Spring context.

When to Use

  • Writing unit tests for Jakarta Bean Validation or JSR-380 constraints
  • Testing custom @Constraint validators and constraint violation messages
  • Testing bean validation logic in DTOs and request objects
  • Verifying cross-field validation (e.g., password matching)
  • Testing conditional validation with validation groups
  • Fast validation tests without Spring Boot context

Instructions

Details

Repository
github.com/giuseppe-trisciuoglio/developer-kit
Categories
Testing & QA, Java & JVM

More from giuseppe-trisciuoglio/developer-kit

All 95

Similar to Unit Test Bean Validation

More Testing & QA