我正在将 gradle 版本升级到 6.8.1。出于测试目的。我在 build.gradle 中添加了依赖testCompile gradleTestKit( ) 但我的集成测试用例失败并出现以下错误。我尝试升级到 Junit 5、spock 2.0-groovy-2.5 和 groovy 2.5.12。
代码:
def runner = GradleRunner.create()
.withProjectDir(this.testDir)
.withPluginClasspath()
withPluginClasspath()方法获取异常。
测试用例:
def "Make sure a build runs successfully"() {
when:
def result = build 'compileJava'
错误:
Test runtime classpath does not contain plugin metadata file 'plugin-under-test-metadata.properties'
org.gradle.testkit.runner.InvalidPluginMetadataException: Test runtime classpath does not contain plugin metadata file 'plugin-under-test-metadata.properties'
at org.gradle.testkit.runner.internal.PluginUnderTestMetadataReading.readImplementationClasspath(PluginUnderTestMetadataReading.java:44)
at org.gradle.testkit.runner.internal.PluginUnderTestMetadataReading.readImplementationClasspath(PluginUnderTestMetadataReading.java:37)
at org.gradle.testkit.runner.internal.DefaultGradleRunner.withPluginClasspath(DefaultGradleRunner.java:162)