Reputation: 1
I'm encountering an IllegalStateException
when running integration tests for my Spring Boot application. The error seems related to Flyway attempting to connect to PostgreSQL during the tests, even though I have disabled Flyway in the application-test.properties
file.
@ActiveProfiles("test")
@SpringBootTest(classes = SampleApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ExtendWith(SpringExtension.class)
public abstract class AbstractSpringIntegrationTest{
@LocalServerPort
public int port;
}
public class SampleControllerTest extends AbstractSpringIntegrationTest {
@MockBean
private SampleService sampleService;
@Autowired
private ObjectMapper objectMapper;
@Test
void testMethodSuccess() { ...... }
Below is my test/resources/application-test.properties which i have created specific to testcases.
# Disable Flyway for tests
spring.flyway.enabled=false
while running the testcase i got the below error message
SampleControllerTest > testMethodSuccess() FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:180
Caused by: org.flywaydb.core.internal.exception.FlywaySqlException at JdbcUtils.java:60
Caused by: org.postgresql.util.PSQLException at ConnectionFactoryImpl.java:346
Caused by: java.net.ConnectException at Net.java:-2
what am i missing here?
Even with Flyway disabled in application-test.properties
, it seems like Flyway is still trying to perform migrations and connect to PostgreSQL, leading to a ConnectException
.
What I Have Tried:
Verified that spring.flyway.enabled=false
is correctly set.
Checked if there are any other configurations that might be triggering Flyway or PostgreSQL connections during tests.
How can I resolve this issue so that my integration tests run without trying to connect to PostgreSQL and without Flyway attempting to perform migrations?
Upvotes: 0
Views: 70