春天 - 跳过这个测试的飞行路线

问题描述 投票:2回答:1

与flyway的Spring Boot Web应用程序。

所以我从使用H2切换到MySQL,并在必要时使用Testcontainers为我的后端测试提供数据库。

这意味着我所有的其他集成测试(不需要数据库但需要加载spring应用程序上下文) - 例如UI测试 - 现在失败,因为他们没有DB来执行flyway迁移。

[...]
[main] WARN  com.zaxxer.hikari.util.DriverDataSource - Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
[main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
    [...]
    at org.flywaydb.core.internal.database.DatabaseFactory.createDatabase(DatabaseFactory.java:72)
    at org.flywaydb.core.Flyway.execute(Flyway.java:1670)
    at org.flywaydb.core.Flyway.migrate(Flyway.java:1356)
    [...]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350
    [...]

如何暂停这些测试的飞路迁移?

java spring spring-boot kotlin flyway
1个回答
0
投票

你应该设置spring.flyway.enabled=false。这可以使用测试中的特殊配置文件或在测试中使用TestPropertySource注释来完成。

© www.soinside.com 2019 - 2024. All rights reserved.