Christian
Christian

Reputation: 313

Micronaut switching from 2.0.0.M3 to RC1: Gradle executes no tests anymore

today I've switched from Micronaut 2.0.0.M3 to its RC1. After that Gradle does not execute test jobs anymore, reproducibly.

Output running M3:

$ cat gradle.properties 
micronautVersion=2.0.0.M3

$ ./gradlew clean build

> Configure project :
Executed by Gradle 6.5

> Task :compileJava
Note: Creating bean classes for 4 type elements

> Task :compileTestGroovy
[...]

> Task :test
[...]

BUILD SUCCESSFUL in 25s
14 actionable tasks: 14 executed

$ ls build/test-results/test/
binary
TEST-server.endpoint.ContributorControllerTest.xml
TEST-server.endpoint.PersonControllerTest.xml

With RC1:

$ cat gradle.properties 
micronautVersion=2.0.0.RC1

$ ./gradlew clean build

> Configure project :
Executed by Gradle 6.5

> Task :compileJava
Note: Creating bean classes for 4 type elements

[...]

BUILD SUCCESSFUL in 14s
14 actionable tasks: 14 executed

$ ls build/test-results/test/
binary

$ ls -s build/test-results/test/binary/
0 output.bin
4 output.bin.idx
0 results.bin

No XML files with test results are created; binary test output files are empty.
Very weird, indeed. Any idea what went wrong here?

Christian


Addition to answer comment from @saw303:
First I ran clean build again:

$ cat gradle.properties 
micronautVersion=2.0.0.RC1

$ ./gradlew clean build

> Configure project :
Executed by Gradle 6.5
- using Java 11.0.7
- using Groovy 2.5.11

> Task :compileJava
Note: Creating bean classes for 4 type elements

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 12s
14 actionable tasks: 14 executed

Now let's try it with task test:

$ ./gradlew test

> Configure project :
Executed by Gradle 6.5
- using Java 11.0.7
- using Groovy 2.5.11

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 658ms
5 actionable tasks: 5 up-to-date

Very short execution time, so no execution of any test cases!

$ ls build/test-results/test/
binary

Running clean test:

$ ./gradlew clean test

> Configure project :
Executed by Gradle 6.5
- using Java 11.0.7
- using Groovy 2.5.11

> Task :compileJava
Note: Creating bean classes for 4 type elements

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 5s
6 actionable tasks: 6 executed

Same result, not tests were executed:

$ ls build/test-results/test/
binary

Upvotes: 2

Views: 180

Answers (2)

Christian
Christian

Reputation: 313

OK, after fiddling around a lot with a freshly setup Micronaut environment (as recommended by @saw303) I've figured out that with my project the following code block in build.gradle is required to get tests executed when using Micronaut 2.0.0.RC1:

// use JUnit 5 platform
test {
    useJUnitPlatform()
}

When this block is missing, tests are compiled but NOT executed. With previous Micronaut 2.0.0.M3 this useJUnitPlatform() was not required, tests are executed without this addition.

Upvotes: 0

saw303
saw303

Reputation: 9072

I noticed that the build.gradle between 2.0.M3 and 2.0.RC1 changed slighly when it comes to declaring test dependencies.

In our projects we write tests in Spock.

Previous to RC1 the test dependencies have been declared such as:

    testAnnotationProcessor(platform("io.micronaut:micronaut-bom:$micronautVersion"))
    testAnnotationProcessor("io.micronaut:micronaut-inject-java")
    testImplementation(platform("io.micronaut:micronaut-bom:$micronautVersion"))
    testImplementation("org.junit.jupiter:junit-jupiter-api")
    testImplementation("io.micronaut.test:micronaut-test-junit5")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

In RC1 the test dependencies are declared like:

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

At https://micronaut.io/launch/ you can play around with the latest version of Micronaut and preview the build.gradle. Hope this helps

Upvotes: 1

Related Questions