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

怎甘沉沦 提交于 2020-01-21 15:06:05

问题


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:

  • How to use JUnit 5 with Gradle?
  • How to create an HTML report for JUnit 5 tests?

And well I am using

test {
    useJUnitPlatform()      
}

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


回答1:


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



来源:https://stackoverflow.com/questions/49922797/configuration-for-gradle-4-7-to-generate-the-html-report-for-junit-5-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!