I use junit5 with spring-starter-test, in order to run spring test I need to use @ExtendWith
instead of @RunWith
. However @IfProfileValue
work with @RunWith(SpringRunner.class)
but not with @ExtendWith(SpringExtension.class)
, below is my code:
@SpringBootTest
@ExtendWith({SpringExtension.class})
class MyApplicationTests{
@Test
@DisplayName("Application Context should be loaded")
@IfProfileValue(name = "test-groups" , value="unit-test")
void contextLoads() {
}
}
so the contextLoads should be ignore since it didn't specify the env test-grooups. but the test just run and ignore the @IfProfileValue
.