Which version of spring boot contains @WebIntegrationTest, it shows red in Intellij during add

I have a Spring test boot file dependency added to my Gradle file like

testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
ext['mockito.version'] = '2.7.5'

      

Unable to use @WebIntegrationTest

, it shows red if I try to add to Intellij. What should I have in my application so that I can test the REST API using @WebIntegrationTest

?

I can test it with a different method but just can't figure out why it is failing

+3


source to share


3 answers


Can't use @WebIntegrationTest yet, it shows red if I try to add to intellij.

As you said you have version 1.5.1 of Springboot, the class is WebIntegrationTest

deprecated from 1.4 in favor of SpringBootTest

.

Below is the javadocs support.

  • @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 {


Here you have two options:

  • Class WebIntegrationTest

    and start usingSpringBootTest

  • Downgraded version lower than 1.4.0 and use WebIntegrationTest

    (not recommended)

Here is a link in the 1.4.0-M2 release notes explaining about the cancellation WebIntegrationTest

Hope this helps!

+5


source


Of

org.springframework.boot.test.WebIntegrationTest

      



javadoc (emphasis mine)

This annotation can be used as an alternative to @IntegrationTest and @WebAppConfiguration. Since: 1.2.1

0


source


These deprecated annotations

@SpringApplicationConfiguration(classes = arrayOf(BootApplication::class))
@WebIntegrationTest("server.port=8081")

      

in Spring Boot 1.5+ is equivalent to

@SpringBootTest(classes = arrayOf(BootApplication::class), properties = arrayOf("server.port=8081"))
@WebAppConfiguration

      

0


source







All Articles