1

I am upgrading gradle version to 6.8.1.For testing purpose. I am adding the dependency testCompile gradleTestKit() in build.gradle but my intergation test case are failing with below error. I tried upgrading to Junit 5, spock 2.0-groovy-2.5 & groovy 2.5.12.

Code:

def runner = GradleRunner.create()
            .withProjectDir(this.testDir)
            .withPluginClasspath()   

withPluginClasspath() method getting the exception.

Test case:

def "Make sure a build runs successfully"() {
        when:
        def result = build 'compileJava'

Error:

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)
Sam
  • 728
  • 1
  • 9
  • 26

2 Answers2

0

I fixed this issue by changing integration tests settings in build.gradle:

integTest {
    // old code had "configurations.testRuntime" at the end
    compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
}
kinORnirvana
  • 1,667
  • 2
  • 17
  • 22
  • what the actual.. thank you, I was upgrading a project from gradle 4 to gradle 7 and was scratching my head the entire time wondering what was wrong – Toofy Jan 13 '22 at 00:36
-1

I fixed this issue by adding 'plugin-under-test-metadata.properties' file in my src/resources folder as I noticed classpath is reading from src folder.

Sam
  • 728
  • 1
  • 9
  • 26