@SpringApplicationConfiguration(classes = Array(classOf[ApplicationConfig])) @WebAppConfiguration @IntegrationTest(value = Array("server.port:0")) @DirtiesContext class ApplicationTest extends AssertionsForJUnit { @Value("${local.server.port}") var port: Int = _ new TestContextManager(classOf[ApplicationTest]).prepareTestInstance(this) @Test def integrationTest: Unit = { val entity = new TestRestTemplate().getForEntity("http://localhost:" + port + "/health", classOf[String]); Assert.assertThat(entity.getStatusCode, CoreMatchers.is(HttpStatus.OK)) } }