配置Gradle 4.7以生成JUnit 5测试的HTML报告 [英] Configuration for Gradle 4.7 to generate the HTML report for JUnit 5 tests

查看:297
本文介绍了配置Gradle 4.7以生成JUnit 5测试的HTML报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于以下内容的应用程序:

I have an app based as follows:

  • Spring Framework 5.0.4.发布
  • Gradle 4.7 -通过
  • 配置的多模块项目
  • JUnit 5.1.1
  • Spring Framework 5.0.4.RELEASE
  • Gradle 4.7 - multimodule project configured through
  • JUnit 5.1.1

有关带有JUnit的Gradle的配置位于根模块中的build.gradle文件中:

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"
    }

}

通过Jenkins我执行:

  • gradle :thymeleaf-02-infrastructure:test --parallel
  • 并与Publish JUnit test result report一起配置为thymeleaf-02-infrastructure/build/test-results/junit-platform/*.xml
  • 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

从头开始,一切正常,我可以在Jenkins中看到传递的@Test,但是Gradle不会使用预期的html文件生成report目录.

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.

即使直接在终端中执行gradle :thymeleaf-02-infrastructure:test --parallel命令,所有工作(测试通过),但Gradle不会使用预期的html文件生成report目录.

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?

我正在使用

test {
    useJUnitPlatform()      
}

Gradle> 4.6 4.7 ,那么缺少什么?

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

推荐答案

您需要删除org.junit.platform.gradle.plugin,因为它默认情况下会禁用标准的test任务.

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

这篇关于配置Gradle 4.7以生成JUnit 5测试的HTML报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆