I do the migration from a Spring Boot reactive to mvc. I migrated controllers and now I try to migrate integration tests.
Controller's tests are annotated like this and if I run test it works.
@RunWith(SpringRunner.class)
@WebFluxTest
public class MyIntegrationTest {
}
Then I replace WebFluxTest
annotation like this
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWebTestClient
public class MyIntegrationTest {
}
If I run this test I have reactor.core.Exceptions$ReactiveException: io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:8080
. Any ideas how to fix it?
Will load and start your full application on a random port.
Will load up a mock of your application and then configure a WebTestClient to go to that mock.
You are telling Spring to start an application AND to load a mock.
All this is explained very good in the documentation so please read there and then decide if you wish to load your entire application, or just mocks of it while executing your tests.
Testing Spring boot applications
Tests with a running server
Tests with a mock environment