Spring Boot do a lot of automatically things to us but when we use the annotation @SpringBootTest
we think that everything will be automatically solved by Spring boot.
There are a lot of documentation, but the minimal is to choose one engine (@RunWith(SpringRunner.class)
) and indicate the class that will be used create the context to load the configuration (resources/applicationl.properties
).
In a simple way you need the engine and the context:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MyClassTest .class)
public class MyClassTest {
@Value("${my.property}")
private String myProperty;
@Test
public void checkMyProperty(){
Assert.assertNotNull(my.property);
}
}
Of course, if you look the Spring Boot documentation you will find thousands os ways to do that.