gradlegroovybuild.gradlegradle-plugintestkit

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


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)

Solution

  • 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.