配置Gradle 4.7以生成JUnit 5测试的HTML报告 [英] 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.发布 -
Gradle
4.7 -通过 配置的多模块项目
-
JUnit
5.1.1
Spring Framework
5.0.4.RELEASEGradle
4.7 - multimodule project configured throughJUnit
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 tothymeleaf-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屋!