lundi 7 octobre 2019

"lateinit property

I can not figure out how to get the WebTestClient initialized when using Kotlin and Spring Boot Tests.

@ExtendWith(SpringExtension::class, MockKExtension::class)
@AutoConfigureWebTestClient
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class GraphQlClientIntegrationTest {
    private val testToken = "aUna%14OkmUZunb528342"

    @Autowired
    lateinit var client: WebTestClient

    @InjectMockKs
    lateinit var gateGraphQlClient: GateGraphQlClient

    @Test
    fun shouldAddAuthorization() {
        val ID = Id(UUID.randomUUID().toString())
        val returnResult = client.post()
                .uri("/graphql")
                .header(HttpHeaders.AUTHORIZATION, testToken)
                .exchange()
                .expectStatus().isOk
                .returnResult(ObjectNode::class.java)
    }
}

This is the error message

lateinit property client has not been initialized
kotlin.UninitializedPropertyAccessException: lateinit property client has not been initialized

Aucun commentaire:

Enregistrer un commentaire