关于 Eclipse 的 JUnit 报告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1922467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:13:29  来源:igfitidea点击:

JUnit report on Eclipse

javaeclipsejunit

提问by Mario Ortegón

The JUnit integration with eclipse is very nice. However, I would like a feature to be able to generate a quick report from the Unit Tests. It is possible to do so when running a headless build (and my nightly build is configured to do so), but sometimes I want to generate a report from the UI.

JUnit 与 eclipse 的集成非常好。但是,我想要一个能够从单元测试生成快速报告的功能。在运行无头构建时可以这样做(我的夜间构建配置为这样做),但有时我想从 UI 生成报告。

Is there anyway to do this? command line options maybe? an extra plugin? maybe the functionality is already there and I can't find it?

有没有办法做到这一点?命令行选项可能吗?一个额外的插件?也许功能已经存在而我找不到它?

EDIT: I have a PDE build, as my project is an RCP application. Thus, running the tests from this build is not really straight-forward. I guess I could try to hack a smaller ANT script to do the test, but then probably I have to fight with the classpath to obtain what I want. I was hoping to find some extension to the already existing JUnit plugin that would provide the information on the tree view, but as an HTML document.

编辑:我有一个 PDE 版本,因为我的项目是一个 RCP 应用程序。因此,从这个构建运行测试并不是很简单。我想我可以尝试破解一个较小的 ANT 脚本来进行测试,但是可能我必须与类路径斗争才能获得我想要的东西。我希望找到对现有 JUnit 插件的一些扩展,以提供有关树视图的信息,但作为 HTML 文档。

回答by Sajad Bahmani

You can use ant and generate HTML report [I think you can use Ant in Eclipse]
I found these link but you can survey more:

您可以使用 ant 并生成 HTML 报告 [我认为您可以在 Eclipse 中使用 Ant]
我找到了这些链接,但您可以调查更多:

Ant JUnitReport Task
JUnit Tutorial
JUint Report

Ant JUnitReport 任务
JUnit 教程
JUint 报告

回答by austen

I'm not sure if you want a "physical" report that you can distribution or just more information you can view in your IDE.

我不确定您是否需要可以分发的“物理”报告,或者只是可以在 IDE 中查看的更多信息。

Either way I agree with SjB's advice on configuring Eclipse to run the ant script generating the report in your nightly build.

无论哪种方式,我都同意 SjB 的建议,即配置 Eclipse 以运行在每晚构建中生成报告的 ant 脚本。

If it's not possible to run the nightly build locally, you can do some very simple build script hacking following the links in SjB's answer.

如果无法在本地运行每晚构建,您可以按照 SjB 回答中的链接进行一些非常简单的构建脚本黑客攻击。

You also might want to check out the Ant JUnit Task Manual Page

您可能还想查看Ant JUnit 任务手册页