Я работаю над проектом весенней загрузки / gradle и по какой-то причине задача Gradle запуска flywayMigrate во время модульного тестирования, поэтому она не удалась.
Error occurred while executing flywayMigrate. Connection refused
Я запускаю тесты с . / Gradlew clean test
My build.gradle file:
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'nu.studer.jooq' version '4.1'
id "org.flywaydb.flyway" version "6.2.0"
}
group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
ext {
dbUrl = "jdbc:postgresql://localhost:5432/test"
dbUsername = 'admin'
dbPassword = 'admin'
dbDriver = 'org.postgresql.Driver'
dbSchema = 'public'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-jooq'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'javax.xml.bind:jaxb-api:2.3.0'
implementation 'org.flywaydb:flyway-core'
implementation 'org.postgresql:postgresql:42.2.9'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
jooqRuntime 'org.postgresql:postgresql:42.2.9'
compile 'org.jooq:jooq'
}
test {
useJUnit()
}
jooq {
version = '3.11.0'
edition = 'OSS'
sample(sourceSets.main) {
jdbc {
driver = dbDriver
url = dbUrl
user = dbUsername
password = dbPassword
schema = dbSchema
}
generator {
database {
inputSchema = dbSchema
excludes = 'databasechangelog|databasechangeloglock'
}
generate {
relations = false
deprecated = false
records = true
immutablePojos = false
fluentSetters = false
javaTimeTypes = true
}
target {
directory = 'build/generated/sources/jooq'
packageName = 'com.test.generated.models'
}
}
}
}
flyway {
url = dbUrl
user = dbUsername
password = dbPassword
schemas = [dbSchema]
locations = ["filesystem:$project.projectDir/src/main/resources/db/migration"]
}
generateSampleJooqSchemaSource.dependsOn flywayMigrate
Я не пытаюсь запустить интеграционные тесты. Только единицы, поэтому мне не нужно соединение с БД. FlywayMigration хорошо работает с gradlew bootRun