diff --git a/README.adoc b/README.adoc index 16aed7a..48c8cbd 100644 --- a/README.adoc +++ b/README.adoc @@ -270,12 +270,14 @@ dependencies { } ---- -Refresh Gradle configuration, and open `BlogApplicationTests` to replace `@RunWith(SpringRunner::class)` by `@ExtendWith(SpringExtension::class)`. +Refresh Gradle configuration, open `BlogApplicationTests` and update imports as bellow and remove `@RunWith(SpringRunner::class)` since `@SpringBootTest` is already annotated with JUnit 5 `@ExtendWith(SpringExtension::class)` as of Spring Boot 2.1. `src/test/kotlin/blog/BlogApplicationTests.kt` [source,kotlin] ---- -@ExtendWith(SpringExtension::class) +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + @SpringBootTest class BlogApplicationTests { diff --git a/src/test/kotlin/blog/BlogApplicationTests.kt b/src/test/kotlin/blog/BlogApplicationTests.kt index c4861e5..f70f0b0 100644 --- a/src/test/kotlin/blog/BlogApplicationTests.kt +++ b/src/test/kotlin/blog/BlogApplicationTests.kt @@ -1,11 +1,8 @@ package blog import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith import org.springframework.boot.test.context.SpringBootTest -import org.springframework.test.context.junit.jupiter.SpringExtension -@ExtendWith(SpringExtension::class) @SpringBootTest class BlogApplicationTests { diff --git a/src/test/kotlin/blog/HttpApiTests.kt b/src/test/kotlin/blog/HttpApiTests.kt index 108e384..ed028b7 100644 --- a/src/test/kotlin/blog/HttpApiTests.kt +++ b/src/test/kotlin/blog/HttpApiTests.kt @@ -2,10 +2,8 @@ package blog import com.nhaarman.mockito_kotlin.whenever import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest -import org.springframework.test.context.junit.jupiter.SpringExtension import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get @@ -13,7 +11,6 @@ import org.mockito.Mockito.any import org.springframework.http.MediaType import org.springframework.test.web.servlet.result.MockMvcResultMatchers.* -@ExtendWith(SpringExtension::class) @WebMvcTest // TODO Use constructor-based val property for @MockBean when supported, see issue spring-boot#13113 class HttpApiTests(@Autowired val mockMvc: MockMvc) { diff --git a/src/test/kotlin/blog/IntegrationTests.kt b/src/test/kotlin/blog/IntegrationTests.kt index 6d379e9..8fb4517 100644 --- a/src/test/kotlin/blog/IntegrationTests.kt +++ b/src/test/kotlin/blog/IntegrationTests.kt @@ -4,16 +4,12 @@ import org.assertj.core.api.Assertions.* import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.web.client.TestRestTemplate import org.springframework.boot.test.web.client.getForEntity -import org.springframework.boot.test.web.client.getForObject import org.springframework.http.HttpStatus -import org.springframework.test.context.junit.jupiter.SpringExtension -@ExtendWith(SpringExtension::class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class IntegrationTests(@Autowired val restTemplate: TestRestTemplate) { diff --git a/src/test/kotlin/blog/RepositoriesTests.kt b/src/test/kotlin/blog/RepositoriesTests.kt index 0b0133f..6b06ffa 100644 --- a/src/test/kotlin/blog/RepositoriesTests.kt +++ b/src/test/kotlin/blog/RepositoriesTests.kt @@ -2,13 +2,10 @@ package blog import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager -import org.springframework.test.context.junit.jupiter.SpringExtension -@ExtendWith(SpringExtension::class) @DataJpaTest class RepositoriesTests(@Autowired val entityManager: TestEntityManager, @Autowired val userRepository: UserRepository,