Validate your yml properties as part of your CI build. Unit test that validates yml files.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Validate all YML files as part of your CI build

This test can be used to validate spring boot (or other) yml files as part of the compilation process. It is primarily aimed at validating basic markup errors and does not know anything about how the properties are actually ued. This test should work on all yml files

  1. Copy the test class ValidateSpringYml from src/test/java/org/springframework/beans/factory/config to the same package location in your project's test source tree.
  2. Edit the @Test methods to meet your needs. Alternatively, retain validateAllYml() which will validate all application and test yml files.

Test log output

Logging output does not appear on the console when running gradle test. Logging output is available at

  • build/reports/test/classes as html
  • buld/test-results/test as xml

Example Notes

  1. This project contains one good and one bad yml file. The "*" test fails because int validates all yml files on the path including the bad yml file in src/test/resources
  2. The test class must be in the spring package because it accesses protected code.


This project was built with the following

  1. Java 8
  2. Gradle 4.2
  3. You can crate a gradle wrapper by running the following command gradle wrapper --gradle-version 4.2