I have built a spring boot application. We are using flyway to manage our DB migrations. Whenever I start the maven build for my application, it basically tries to establish a connection with the database and fails. I am trying to disable this "connection to DB" step.
Now here are the solutions that I have tried:
- I have created a separate profile called
test
and I have disabled the flyway as below:
spring:
application:
name: ${APP_NAME:some-application}
version:
current: ${APP_CURRENT_VERSION:v2}
env:
APP_LOGGING_LEVEL: ${APP_LOGGING_LEVEL:INFO}
flyway:
enabled: false
datasource:
driver: ${RDS_DRIVER:com.mysql.jdbc.Driver}
url: // some FB url
username: // some DB username
password: // some DB password
...
...
...
- I have assigned the profile of
test
to all the unit test files by using@ActiveProfiles("test")
as below:
@SpringBootTest
@RunWith(SpringRunner.class)
@DirtiesContext
@AutoConfigureWebTestClient
@Slf4j
@ActiveProfiles("test")
class RefreshExternalCacheTest {
@Autowired
private RedisAdapter redisAdapter;
...
...
...
}
Even after disabling it through application-test.yml file and applying this profile to all the unit test files, it is still trying to set up the connection with DB. This is causing the unit tests to fail when we run the build via Jenkins.
Is there a way we can disable this setup when running the unit tests?