在gradle html报告中集成ant junit生成的测试结果 [英] integrate ant junit generated test-results in gradle html report

查看:154
本文介绍了在gradle html报告中集成ant junit生成的测试结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my gradle build script, I added doLast method to test task to run ant.junit task to execute tests from few jar files.

    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报告中.但这没有发生.如何获得这种行为?

How do I enhance this task to get the gradle html report benefit? I see that ant junit test xml reports are properly getting created in $buildDir/test-results along with other "gradle test" created xmls. However $buildDir/reports/tests" contains only. I was hoping that gradle will pick up the ant junit created test result xml files as well and include in its html report. But this is not happening. How can I get this behaviour?

我试图创建另一个TestReport类型的任务.但这也没有帮助.

I tried to create another task of type TestReport. But it also did not help.

 task runTestsFromJar( type: TestReport ) {
        destinationDir=file("$buildDir/reports/tests")
        reportOn tasks.test, files("$buildDir/test-results/binary/test")
 }

我正在使用gradle 1.8.

I am working with gradle 1.8.

推荐答案

基于 gradle的响应论坛帖子,看来生成gradle样式的测试html报告无法立即使用gradle.Gradle TestReport任务似乎取决于"test"任务生成的二进制输出文件.使用gradle中的ant.JUnitTask运行测试时不会生成这些文件.最后,我诉诸"ant JUnitReport task"来生成至少一个有意义的合并报告.

Based on the response from gradle forum post, it seems generate gradle styled test html report is not available out-of-the box with gradle. Gradle TestReport task seems to be dependent on the binary output files generated by "test" task. These are not generated when the tests are run using ant.JUnitTask from gradle. I resorted to "ant JUnitReport task" finally to generate at least a meaningful consolidated report.

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

  //after ant junit completion  
   ant.junitReport( toDir: "$buildDir/reports") {
            fileset ( dir:"$buildDir/test-results" )
            report ( format:"frames", todir:"$buildDir/reports" )
   }
}

这给出了基本的html报告.可以根据需要使用XSLT进行自定义.

This gives a basic html report. One can customize as needed using XSLT.

这篇关于在gradle html报告中集成ant junit生成的测试结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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