2

I have an app based as follows:

  • Spring Framework 5.0.4.RELEASE
  • Gradle 4.7 - multimodule project configured through
  • JUnit 5.1.1

The configuration about Gradle with JUnit is in the build.gradle file located in the root module:

...
subprojects {

    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'org.junit.platform.gradle.plugin'

    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'

    repositories {
        jcenter()
    }

    ext {
      ...
      junitVersion = '5.1.1'
      ...
    }

    dependencies {

       ...

       //Testing
       ...
       testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
       testCompile "org.junit.jupiter:junit-jupiter-params:$junitVersion";
       testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
       ....

    }

    test {
        useJUnitPlatform()      
    }

}

//This location is mandatory
buildscript {

    repositories {
        mavenCentral()
    }

    dependencies {      
        classpath "org.junit.platform:junit-platform-gradle-plugin:1.1.0"
    }

}

Through Jenkins I execute:

  • gradle :thymeleaf-02-infrastructure:test --parallel
  • and with Publish JUnit test result report is configured to thymeleaf-02-infrastructure/build/test-results/junit-platform/*.xml

From above all work fine, I can see in Jenkins the @Test passed but Gradle does not generate the report directory with the expected html file.

Even if directly the gradle :thymeleaf-02-infrastructure:test --parallel command is executed in the terminal, all work (tests passe), but Gradle does not generate the report directory with the expected html file.

I already have read these links:

And well I am using

test {
    useJUnitPlatform()      
}

and Gradle is >4.6, 4.7, so what is missing?

Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158

1 Answers1

4

You need to remove the org.junit.platform.gradle.plugin because it disables the standard test task by default.

Marc Philipp
  • 1,848
  • 12
  • 25
  • I tried and sadly it does not work. I can remember I just did do an upgrade from `4.7-rc-2` (there it works) to `4.7`. Not sure was is wrong ... And I tried again with `4.7-rc-2` and **now** does not work too... I did do an upgrade about `JUnit` from `5.1.0` to `5.1.1` – Manuel Jordan Apr 19 '18 at 19:00
  • Can you post a complete sample project? – Marc Philipp Apr 20 '18 at 09:54
  • No, because is huge, but I am going to create one minimum based in multi modules too, thus it to be shared through Github .... – Manuel Jordan Apr 20 '18 at 12:35
  • Something I did realize is that neither `org.junit.platform.gradle.plugin` nor `org.junit.platform:junit-platform-gradle-plugin` are not mentioned in your `Gradle User Guide` link shared ... I will try if it would be the reason ... perhaps both should be not there – Manuel Jordan Apr 20 '18 at 12:46
  • 1
    Indeed, I missed that. I've updated my response accordingly. – Marc Philipp Apr 20 '18 at 16:36
  • Just curious why that plugin has not been removed in the `4.7.x` series ... – Manuel Jordan Apr 20 '18 at 21:04
  • 1
    From Gradle‘s perspective, it‘s a third-party plugin. The Junit team will deprecate it in 5.2 and discontinue it with 5.3. – Marc Philipp Apr 21 '18 at 06:04