Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gradle-如何在itest源集中执行flyway迁移_Gradle_Integration Testing_Flyway - Fatal编程技术网

Gradle-如何在itest源集中执行flyway迁移

Gradle-如何在itest源集中执行flyway迁移,gradle,integration-testing,flyway,Gradle,Integration Testing,Flyway,编辑:问题解决了,因为我注意到: itest未运行,因为test阶段有一些错误,因此下一步itest将无法继续 itest也适用于迁移,我已经仔细检查了日志,可以确认这一点。我在itestlogflyway中搜索,我看到了 所以这个问题是个错误。对不起 我有一个源集: 主要 试验 itest 而itest的定义如下:(project/gradle/integration.gradle) 当我运行gradle-test-itest时,我看到应用了迁移,但当我运行gradle-itest时,

编辑:问题解决了,因为我注意到:

  • itest
    未运行,因为
    test
    阶段有一些错误,因此下一步
    itest
    将无法继续
  • itest
    也适用于迁移,我已经仔细检查了日志,可以确认这一点。我在
    itest
    log
    flyway
    中搜索,我看到了
所以这个问题是个错误。对不起

我有一个源集:

  • 主要
  • 试验
  • itest
itest
的定义如下:(
project/gradle/integration.gradle

当我运行
gradle-test-itest
时,我看到应用了迁移,但当我运行
gradle-itest
时,它们没有应用。我明白,如果我强制
itest
test
之后执行,就像现在一样,我可以确保;但有时我只想运行
itest


如何更改此脚本?

迁移任务运行始终是因为触发了
gradle flywayMigrate
任务

也许某个插件更改了默认设置,使
test
任务依赖于
flywayMigrate

因此,如果您希望自己的任务触发
flywayMigrate
,您可以这样做:

itest.dependsOn flywayMigrate  

// reference:
clean.dependsOn flywayRepair  # To repair the Flyway metadata table
build.dependsOn flywayMigrate  # To migrate the schema to the latest version

您如何为正常测试任务应用迁移?您可能需要对itest执行同样的操作。是的,但在
build.gradle
中,这是no
flywayMigrate
部分。所以我不知道怎么做。@BjørnVester很抱歉,我忘了提到我使用Spring Boot,所以有
FlywayAutoconfiguration
。尝试了,但是
integration.gradle
的解析失败。似乎任务没有在任何地方定义。顺便说一句,我使用的是Spring BootI,我的意思是
flywayMigrate
没有在任何地方找到/定义。这里没有使用gradle flyway插件,这就是flywayMigrate不可用的原因。但是我想做
Flyway.migrate()
就像Spring Boot在
FlywayAutoconfiguration
中做的那样,因为
flywayMigrate
总是需要
Flyway{}
属性,比如
user
url
password
,而且我看不到从
application.yml
读取这些属性的简单方法,特别是当它们是特定于配置文件时。@WesternGun有spring boot自动运行Flyway docs:,他们提供了示例项目:抱歉,但这不是我的情况:我想在另一个源集中迁移Flyway,
itest
,无论是
main
还是
test
。该示例是一个非常基本的示例,只包含
main
test
sourceset。
itest.dependsOn flywayMigrate  

// reference:
clean.dependsOn flywayRepair  # To repair the Flyway metadata table
build.dependsOn flywayMigrate  # To migrate the schema to the latest version