gradle - 在gradle html报告中集成ant junit生成的测试结果

标签 gradle build.gradle

在我的gradle构建脚本中,我添加了doLast方法来测试任务以运行ant.junit任务以从几个jar文件执行测试。

    test <<  {
      //run ant junit task with reports stored in $buildDir/test-results

      //after ant junit completion and "test" task completion, 
      //how can I get the gradle generated html report include the above test-results?    
    }

我如何增强此任务以获得gradle html报告的好处?我看到在$ buildDir / test-results中正确创建了ant junit测试xml报告以及其他“渐变测试”创建的xml。但是$ buildDir / reports / tests”仅包含。我希望gradle也会拾取由ant junit创建的测试结果xml文件,并将其包含在其html报告中。但是这没有发生。如何获得这种行为?

我试图创建另一个TestReport类型的任务。但这也没有帮助。
 task runTestsFromJar( type: TestReport ) {
        destinationDir=file("$buildDir/reports/tests")
        reportOn tasks.test, files("$buildDir/test-results/binary/test")
 }

我正在使用Gradle 1.8。

最佳答案

我建议创建另一个task of type Test来替换您的doAfter闭包。

task antTests(type: Test){
  //configuration here
}

我相信到那时,您可以使用与之前尝试类似的方式来使用TestReport任务
task runTestsFromJar( type: TestReport ) {
    destinationDir=file("$buildDir/reports/tests")
    reportOn test, antTests
}

我尝试基于现有xml结果文件的目录以及binary子文件夹生成报告的尝试也未成功

关于gradle - 在gradle html报告中集成ant junit生成的测试结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21488476/

相关文章:

gradle - 在build.gradle.kts中传递jmeter简单配置时出错

gradle - 在 gradle build.gradle 文件中 - 如何检查项目是否存在?

spring - 运行gradle生成的jar找不到jar条目

android - Kotlin 多平台配置问题

android - ionic : compileSdkVersion is not specified - Could not find method leftShift()

gradle - Artifactory插件似乎忽略了publishPom = false

Android Studio 多个dex文件定义Lcom/abc/xyz/BuildConfig

java - libGDX 设置允许我使用在 Android 中崩溃的 Java 8

android - 尝试对已绑定(bind)的 ID 0 使用 @BindView

android-studio - 如何设置特定于 flavor 和构建类型的 APK 文件名?