Home > database >  Cannot resolve import io.micronaut.test.extensions.spock.annotation.MicronautTest dependency on micr
Cannot resolve import io.micronaut.test.extensions.spock.annotation.MicronautTest dependency on micr

Time:12-16

I want to add spock testing framework in micronaut but so I added these dependencies in micronaut:

    testImplementation "io.micronaut.test:micronaut-test-spock"
    testImplementation("org.spockframework:spock-core") {
        exclude group: "org.codehaus.groovy", module: "groovy-all"
    }

But when I am trying to import io.micronaut.test.extensions.spock.annotation.MicronautTest it is not getting resolved. I also tried clean build.

And I also tried deleting JUnit dependencies from the build.gradle. But this dependency is not being resolved.

CodePudding user response:

For Micronaut 1.3.7 the version of io.micronaut.test:micronaut-test-spock should be 1.1.2. The class io.micronaut.test.extensions.spock.annotation.MicronautTest didn't exist at that time.

Based on the 1.3.7 Documentation, looks like it should be io.micronaut.test.annotation.MicronautTest.

Update:

Created a Micronaut 1.3.7 project.

import io.micronaut.test.annotation.MicronautTest // !!!

@MicronautTest
class DemoTest extends Specification {
}

Notice the import package.

For completeness here were the test dependencies created by the mn cli.

testImplementation platform("io.micronaut:micronaut-bom:$micronautVersion")
testImplementation("org.spockframework:spock-core") {
   exclude group: "org.codehaus.groovy", module: "groovy-all"
}
testImplementation "io.micronaut:micronaut-inject-groovy"
testImplementation "io.micronaut.test:micronaut-test-spock"
testImplementation "io.micronaut.test:micronaut-test-junit5"

Not sure if all are needed and didn't create an actual test case nor did I run the sample application.

  • Related