简体   繁体   English

如何手动生成JUnit测试报告

[英]How to manually generate JUnit test reports

Couldn't come up with a better name. 无法拿出更好的名字。 I'm doing something wrong here, please point in the right direction. 我在这里做错了,请指出正确的方向。

I have a small java app. 我有一个小型的Java应用程序。 We use Jenkins for CI, and (AFAICT) maven-surefire to generate some nice test reports that Jenkins understands. 我们将Jenkins用于CI,并使用(AFAICT)maven-surefire生成Jenkins理解的一些不错的测试报告。 Now, I needed some sanity/acceptance test for my app. 现在,我需要为我的应用程序进行一些健全性/验收测试。 My approach was: 我的方法是:

  • Configure a Jenkins build that will produce an .rpm package and copy it to a temporary VM, along with acceptanceTest.jar 配置一个将生成.rpm软件包的Jenkins构建,并将其与acceptingTest.jar一起复制到一个临时VM中
  • The jar effectively has a runner for the JUnit test case that'll fire up some Jetty/MQ servers, install the rpm, update config and check the test servers are being polled/updated as expected. 这个jar实际上有一个JUnit测试用例的运行器,它将启动一些Jetty / MQ服务器,安装rpm,更新配置,并检查测试服务器是否按预期被轮询/更新。

So far so good - my Jenkins build has a very simple script that does the copying and then runs the jar. 到目前为止,一切都很好-我的Jenkins版本有一个非常简单的脚本,可以执行复制然后运行jar。 If I do it manually, I can see the results on the console. 如果手动执行,则可以在控制台上看到结果。

The problem I now face is generating a test report for Jenkins? 我现在面临的问题是为詹金斯生成测试报告? maven is not installed on the test VM, nor is ant. Maven未安装在测试VM上,Ant也未安装。 Any ideas how I could do this without too much trouble? 有什么想法我可以做到这一点而没有太多麻烦吗?

thanks a lot 非常感谢

The easiest way I can think of is just to install ANT on the test VM. 我能想到的最简单的方法就是在测试VM上安装ANT。 These are the steps: 这些步骤是:

  1. Install ANT 安装ANT
  2. Run the JUnit tests with ANT and specify a directory where the test reports will be created. 使用ANT运行JUnit测试,并指定将在其中创建测试报告的目录。 This is done with the ANT JUnit Task (the batchtest task with the todir directive) 这是通过ANT JUnit任务(带有todir指令的batchtest任务)完成的
  3. Configure Jenkins build to pick up the reports. 配置Jenkins构建以获取报告。 This is done under "Post-build actions": there is a checkbox for "Publish JUnit test result report". 这是在“构建后操作”下完成的:有一个“发布JUnit测试结果报告”复选框。 Click the checkbox and specify the dir where the test reports are. 单击复选框,然后指定测试报告所在的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM