在eclipse中运行JUnit测试后,我可以以XML格式导出结果。如何使用JUnit命令行获取该xml文件? [英] After running JUnit tests in eclipse, I can export the result in XML format. How can I get that xml file using JUnit command line?

查看:752
本文介绍了在eclipse中运行JUnit测试后,我可以以XML格式导出结果。如何使用JUnit命令行获取该xml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Java单元测试,我在Eclipse中使用JUnit插件运行。在eclipse中完成所有测试后,我可以将结果导出为.xml格式,我将其用于将结果上传到测试结果跟踪工具中。

I have Java unit tests which I run using JUnit plugin in Eclipse. After all tests are completed in eclipse, I can export the result in .xml format which I use it to upload the results in test result tracking tool.

现在我在AIX系统中运行相同的测试,我使用命令行来运行JUnit测试。

Now I am running same tests in AIX system where I am using command line to run JUnit tests.

我的命令是

java org.junit.runner.JUnitCore com.rsa.qa.sae.test.testClassName

现在我想在类似的XML文件中获得这些测试的结果。

Now I want to get results of these tests in a similar XML file.

我怎样才能得到它?

推荐答案

基础JUnit库不会生成报告。运行JUnit的各种库( Ant ,Eclipse等)。

The base JUnit library doesn't produce reports. Various libraries that run JUnit do (Ant, Eclipse, etc etc).

如果您不能/不会使用这些工具,那么您需要通过实现 RunListener ,并创建自己的主方法用 JUnitCore 注册它。使用它你可以以你想要的任何形式生成XML。

If you can't/won't use those tools, then you need to generate the report yourself by implementing a RunListener, and creating your own main method that registers it with JUnitCore. Using that you can generate the XML in whatever form you'd like.

类似的问题:

  • Generate XML Files Used by JUnit Reports
  • Generating JUnit reports from the command line

这篇关于在eclipse中运行JUnit测试后,我可以以XML格式导出结果。如何使用JUnit命令行获取该xml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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