Test runtime classpath does not contain plugin metadata file 'plugin-under-test-metadata.properties'

1k views Asked by At

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)
2

There are 2 answers

0
Sam On BEST ANSWER

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.

1
kinORnirvana On

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
}