unit-test-config-properties

Solid

Provides patterns for unit testing `@ConfigurationProperties` classes with `@ConfigurationPropertiesTest`. Validates property binding, tests validation constraints, verifies default values, checks type conversions, and mocks property sources for Spring Boot configuration properties. Use when testing application configuration binding, validating YAML or application.properties files, verifying environment-specific settings, or testing nested property structures.

Testing & QA 261 stars 29 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 89/100

Stars 20%
81
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Unit Testing Configuration Properties and Profiles ## Overview This skill provides patterns for unit testing `@ConfigurationProperties` bindings, environment-specific configurations, and property validation using JUnit 5. Covers testing property name mapping, type conversions, validation constraints, nested structures, and profile-specific configurations without full Spring context startup. **Key validation checkpoints:** - Property prefix matches between `@ConfigurationProperties` and test properties - Validation triggers on `@Validated` classes with invalid values - Type conversions work for Duration, DataSize, collections, and maps ## When to Use - Testing `@ConfigurationProperties` property binding - Testing property name mapping and type conversions - Validating configuration with `@NotBlank`, `@Min`, `@Max`, `@Email` constraints - Testing environment-specific configurations (dev, prod) - Testing nested property structures and collections - Verifying default values when properties are not specified - Fast configuration tests without Spring context startup ## Instructions 1. **Set up test dependencies**: Add `spring-boot-starter-test` and AssertJ dependencies 2. **Use ApplicationContextRunner**: Test property bindings without starting full Spring context 3. **Define property prefixes**: Ensure `@ConfigurationProperties(prefix = "...")` matches test property paths 4. **Test all property paths**: Verify each property including nested structures and collections 5. *...

Details

Author
giuseppe-trisciuoglio
Repository
giuseppe-trisciuoglio/developer-kit
Created
7 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

Testing & QA Solid

unit-test-bean-validation

Provides patterns for unit testing Jakarta Bean Validation (JSR-380), including @Valid, @NotNull, @Min, @Max, @Email constraints with Hibernate Validator. Generates custom validator tests, constraint violation assertions, validation groups, and parameterized validation tests. Validates data integrity logic without Spring context. Use when writing validation tests, bean validation tests, or testing custom constraint validators.

261 Updated 1 weeks ago
giuseppe-trisciuoglio
Testing & QA Solid

unit-test-security-authorization

Provides patterns for unit testing Spring Security with `@PreAuthorize`, `@Secured`, `@RolesAllowed`. Validates role-based access control and authorization policies. Use when testing security configurations and access control logic.

261 Updated 1 weeks ago
giuseppe-trisciuoglio
Testing & QA Solid

property-based-testing

Provides guidance for property-based testing across multiple languages and smart contracts. Use when writing tests, reviewing code with serialization/validation/parsing patterns, designing features, or when property-based testing would provide stronger coverage than example-based tests.

5,487 Updated 3 days ago
trailofbits
Testing & QA Listed

property-based-testing

Provides guidance for property-based testing across multiple languages and smart contracts. Use when writing tests, reviewing code with serialization/validation/parsing patterns, designing features, or when property-based testing would provide stronger coverage than example-based tests.

1 Updated 2 days ago
kevinvwong
Testing & QA Solid

321-frameworks-spring-boot-testing-unit-tests

Use when you need to write unit tests for Spring Boot applications — including pure unit tests with @ExtendWith(MockitoExtension.class) for @Service/@Component, slice tests with @WebMvcTest and @MockitoBean for controllers, @JsonTest for JSON serialization, parameterized tests with @CsvSource/@MethodSource, test profiles, and @TestConfiguration. For framework-agnostic Java use @131-java-testing-unit-testing. For integration tests use @322-frameworks-spring-boot-testing-integration-tests. Part of the skills-for-java project

393 Updated today
jabrena