使用 Eclipse JUnit 插件显示我的测试?
我已经为公司特定的语言编写了一个测试框架。该测试框架能够输出类似 JUnit 的 XML。
例如,我可以将其保存到文件并使用 Eclipse JUnit 视图打开它,或者在我的 Hudson 服务器中显示它。我现在希望将其直接集成到我的 Eclipse 中,以便这些测试在 Eclipse“保存”操作上运行,并将其结果显示在 JUnit 视图中。
最好的方法是什么?
- 将它们保存到文件并在 Eclipse 中打开该文件(如果是这样,该怎么做?)
- 直接用 XML 内容填充 JUnit 视图? (如果是这样,怎么做?)
- 创建我自己的视图(我想这样做,因为我是 SWT 的初学者)
I have written a test framework for a company-specific language. This test framework is able to output JUnit-like XML.
As an example, I can save it to file and open it using Eclipse JUnit view, or disp^lay it in my Hudson server. I want now to have it directly integrated in my Eclipse, in order for these tests to be run on Eclipse "save" action, and for their results to be displayed in a JUnit view.
What is the best way to do that ?
- Save them to file and open that file in Eclipse (and if so, how to do it ?)
- Directly populate a JUnit view with content of XML ? (and if so, how to do it ?)
- Create my own view (which I would like to do, as I'm a complete beginner in SWT)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我看来,最好的方法是创建一个简单的 Eclipse 插件,它可以显示您的视图。 Eclipse 有一个非常好的 API 可以做到这一点,并且有很多文档。根据我实现 Eclipse 插件的经验,您不需要成为一名优秀的 GUI 设计师,因为大多数控件都是编写好的并且您可以重用它。
如果您决定采用这种方式,可以从以下一些资源开始:
插件
使用上下文菜单查看。
希望可以有帮助。
In my opinion the best way is create a simple Eclipse plugin, that shows your view. Eclipse has a pretty good API to do that and there is a lot of documentation. From my experience implementing Eclipse plugins, you don't need to be a good GUI designer since most controls are written and you can reuse it.
If you decide to take this way, here are some resources to start:
plugin
view with context menu.
Hope it helps.
我自己没有尝试过,但我想通过一些技巧,可以在 JUNit 视图中自动打开格式正确的文件。
我认为调用 org.eclipse.ui.ide.IDE.openEditor(IWorkbenchPage, URI, String, boolean) 应该可以。这是因为 JUnit 格式的 xml 文件被设置为使用 JUnit 视图打开。
在此之前,您需要创建一个 Eclipse 插件。这将是一个简单的插件,其中一个类将侦听测试框架的运行完成情况,另一个类将知道在哪里找到生成的 xml 文件并对其调用 openEditor。
I haven't tried this myself, but I imagine that with a little bit of trickery, it would be possible to automatically open a properly formatted file in the JUNit view.
I think a call to
org.eclipse.ui.ide.IDE.openEditor(IWorkbenchPage, URI, String, boolean)
should work. This is because JUnit-formatted xml files are set to be opened with the JUnit view.Before you get to this point, you need to create an Eclipse plugin. This will be a simple plugin that will have one class that will listen for the completion of runs for your testing framework, and another class that will know where to find the resulting xml files and will call openEditor on it.