我有一个运行4个测试类的junit测试套件。当我使用gradle运行测试套件时,它会为套件中的每个测试类创建4个html报告。我是gradle的新手,有没有办法让gradle将结果合并到一个html报告中?
这是我的测试套件。
@RunWith(Suite.class)
@Suite.SuiteClasses([
TestClass1.class,
TestClass2.class,
TestClass3.class,
TestClass4.class,
])
class MyTestSuite {
}在我的gradle.build文件中,我使用了以下测试方法。
test {
include("com/geb/tests/MyTestSuite.class")
jvmArgs '-Dsomevariabe=someValue'
}我使用gradle命令运行我的测试套件:gradle :web-tests:test
然后,当测试套件完成运行时,将为每个类创建4个html文件。保存在web-tests\build\reports\tests\classes中
testClass1.html
testClass2.html
testClass3.html
testClass4.html每个testClass.html文件列出了每个测试用例的通过或失败状态。
我希望有一个包含所有测试用例通过或失败状态的组合列表的单个html文件。这个是可能的吗?
发布于 2021-10-26 13:18:04
This plugin可以帮助您。将此代码添加到您的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.kncept.junit.reporter:junit-reporter:2.1.0'
}
}
plugins {
id 'com.kncept.junit.reporter' version '2.1.0'
}
apply plugin: 'com.kncept.junit.reporter'
junitHtmlReport {
// The maximum depth to traverse from the results dir.
// Any eligible reports will be included
maxDepth = 5
// Directory where to search (exact or relative to build path)
testResultsDir = '/path/to/root/of/project'
// Where to output
testReportsDir = 'reports/junit'
// Fail build when no XML files to process
failOnEmpty = true
}现在使用以下命令构建报告:./gradlew junitHtmlReport
为./reports/junit创建它找到的所有JUnit XML文件的超文本标记语言报告。注意,这组合了像TEST-*.xml这样的文件,而不是html文件。
https://stackoverflow.com/questions/38332260
复制相似问题