I have Spring Boot test dependency added in Gradle file as
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
ext['mockito.version'] = '2.7.5'
Still not able to use @WebIntegrationTest, it shows red color if I try to add in Intellij. What should I have in my application so that I would be able to test REST API with @WebIntegrationTest?
I'm able to test it with different method but just not able to get why it is failing
Still not able to use @WebIntegrationTest, it shows red color if I try to add in intellij.
As said by you that you have springboot 1.5.1 version, WebIntegrationTest class was deprecated from 1.4 in favor of SpringBootTest.
Below is the javadocs supporting above.
- @since 1.2.1 * @see IntegrationTest * @deprecated as of 1.4 in favor of * {@link org.springframework.boot.test.context.SpringBootTest} with * {@code webEnvironment=RANDOM_PORT} or {@code webEnvironment=DEFINED_PORT}. */ @Documented @Inherited @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @BootstrapWith(WebAppIntegrationTestContextBootstrapper.class) @Deprecated public @interface WebIntegrationTest {
You have two choices here,
WebIntegrationTest class and start using SpringBootTest
WebIntegrationTest(not recommended)Here is the link of 1.4.0-M2 release notes explaining about the deprecation of WebIntegrationTest
Hope this helps!
These deprecated annotations
@SpringApplicationConfiguration(classes = arrayOf(BootApplication::class))
@WebIntegrationTest("server.port=8081")
in Spring Boot 1.5+ are equivalent to
@SpringBootTest(classes = arrayOf(BootApplication::class), properties = arrayOf("server.port=8081"))
@WebAppConfiguration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With