I use Spring boot + Spring Security + Spring Actuator
My JUnit test class:
@RunWith(SpringRunner.class)
@SpringBootTest()
@AutoConfigureMockMvc
public class ActuatorTests {
@Autowired
private MockMvc mockMvc;
@Test
@WithMockUser(roles={"USER","SUPERUSER"})
public void getHealth() throws Exception {
mockMvc.perform(get("/health"))
.andExpect(status().isOk());
}
}
is OK, but when I set management.port: 8088
, my test is KO with this message:
[ERROR] ActuatorTests.getHealth:37 Status expected:<200> but was:<404>
How to set management port in my JUnit test MockMvc or test configuration?