Since Spring Boot 2.4.0, the /actuator/prometheus endpoint is not found in tests using @SpringBootTest, but it is available when running the application. This didn't occur in the previous versions of spring-boot. An example project to replicate the issue is available at https://github.com/gmariotti/spring-boot-bug.

Test example:

import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.web.reactive.server.WebTestClient

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class SpringBootApplicationTest {

    @Autowired lateinit var client: WebTestClient

    @ParameterizedTest
    @ValueSource(strings = ["/health/liveness", "/health/readiness", "/prometheus"])
    fun `verify default endpoints are available`(endpoint: String) {
        client
            .get()
            .uri("/actuator/$endpoint")
            .exchange()
            .expectStatus().is2xxSuccessful
    }
}

Comment From: snicoll

@gmariotti thanks for the report but this is intended. Please review the release notes before upgrading. There is a dedicated section about this change.

Comment From: gmariotti

So sorry @snicoll, no clue how I missed that 🙇