I would like to test the resilience of a Spring Bean which it loads the configuration from a YML file.
In a test, I load a corrupt configuration in order to test if the annotation @Validated run in the proper way:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ServiceExample.class})
@Category({Fast.class})
@ActiveProfiles("profileWithBadConfiguration")
public class ServiceExampleTest {
@Test(expected=IllegalStateException.class)
public void test1() {
}
}
When I try to test execute the test "test1", the JUnit file crash before executing the first tests. The idea is to detect the IllegalStateException in a Test.
Anyone knows, how to test it?
Technical links:
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/validation/annotation/Validated.html https://docs.spring.io/spring/docs/4.1.x/spring-framework-reference/html/validation.html
Many thanks in advance
Juan Antonio