简体   繁体   中英

Configuration for Gradle 4.7 to generate the HTML report for JUnit 5 tests

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?

您需要删除org.junit.platform.gradle.plugin因为它默认禁用标准test任务。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM