unit-test-config-properties

Validate Spring @ConfigurationProperties binding and validation with ApplicationContextRunner.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/rizaldiem/digital-invitation-web_V2 --skill unit-test-config-properties-rizaldiem
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unit-test-config-properties
Source: https://github.com/rizaldiem/digital-invitation-web_V2/tree/main/.windsurf/skills/unit-test-config-properties
Command: npx skills add https://github.com/rizaldiem/digital-invitation-web_V2 --skill unit-test-config-properties-rizaldiem

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Verifies that Spring @ConfigurationProperties classes bind application properties correctly and enforce validation without launching a full Spring context, reducing slow integration tests and catching configuration errors early.

Core Features & Use Cases

  • Isolated binding tests using ApplicationContextRunner to assert property mapping and default values.
  • Validation checks for constraints such as @NotBlank, @Min/@Max, @Positive and constructor-binding scenarios.
  • Type conversion and structure tests for Duration, DataSize, lists, maps, nested objects, and indexed lists.
  • Profile-specific verification to ensure @Profile configurations and environment-specific beans behave as expected.
  • Use Case: Quickly confirm that a new configuration key maps to the intended Java field, converts to the right type, and fails validation when misconfigured.

Quick Start

Run an ApplicationContextRunner unit test that provides explicit property values and asserts binding, defaults, conversions, and validation for your @ConfigurationProperties class.

Frequently Asked Questions about unit-test-config-properties

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

FAQPage Schema
How do I unit test Spring Boot configuration properties binding without starting the full application context?

You can unit test Spring Boot configuration properties binding in isolation using ApplicationContextRunner. It verifies property mapping, defaults, and validation constraints without launching a full Spring context, catching configuration errors early.

What is ApplicationContextRunner used for in Spring Boot configuration testing?

ApplicationContextRunner is a testing utility for isolated binding tests. It asserts property mapping and default values for @ConfigurationProperties classes without the overhead of slow integration tests that start a full Spring context.

Does ApplicationContextRunner support type conversion testing for Duration and DataSize in configuration properties?

Yes, ApplicationContextRunner supports type conversion and structure tests for Duration, DataSize, lists, maps, nested objects, and indexed lists. It verifies that configuration keys convert to the correct Java types during property binding.

How do I test validation constraints on @ConfigurationProperties classes with JUnit 5?

Use ApplicationContextRunner with JUnit 5 to test validation constraints such as @NotBlank, @Min, @Max, and @Positive. Provide explicit misconfigured property values and assert that binding fails as expected.

Can I verify profile-specific Spring configuration properties in isolated unit tests?

Yes, you can perform profile-specific verification using ApplicationContextRunner to ensure @Profile configurations and environment-specific beans behave as expected when binding @ConfigurationProperties classes.

What is the best way to test nested collection binding in Spring Boot configuration properties?

The best way to test nested collection binding is using ApplicationContextRunner to assert type conversion and structure for lists, maps, and nested objects. It confirms that complex property structures map accurately to Java fields.