使用Eclipse JUnit插件显示我的测试?

时间:2023-01-14 14:51:29

I have written a test framework for a company-specific language. This test framework is able to output JUnit-like XML.

我为公司特定的语言编写了一个测试框架。该测试框架能够输出类似JUnit的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.

作为一个例子,我可以将它保存到文件并使用Eclipse JUnit视图打开它,或者将它放在我的Hudson服务器中。我现在想要将它直接集成到我的Eclipse中,以便在Eclipse“save”操作上运行这些测试,并将它们的结果显示在JUnit视图中。

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 ?)
  • 将它们保存到文件并在Eclipse中打开该文件(如果是,如何操作?)

  • Directly populate a JUnit view with content of XML ? (and if so, how to do it ?)
  • 使用XML内容直接填充JUnit视图? (如果是的话,怎么做?)

  • Create my own view (which I would like to do, as I'm a complete beginner in SWT)
  • 创建我自己的视图(我想做的,因为我是SWT的完全初学者)

2 个解决方案

#1


1  

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.

我自己没有尝试过,但我想通过一些技巧,可以在JUNit视图中自动打开格式正确的文件。

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.

我认为对org.eclipse.ui.ide.IDE.openEditor(IWorkbenchPage,URI,String,boolean)的调用应该有效。这是因为JUnit格式的xml文件设置为使用JUnit视图打开。

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.

在开始这一点之前,您需要创建一个Eclipse插件。这将是一个简单的插件,它将有一个类将监听测试框架的运行完成,另一个类将知道在哪里找到生成的xml文件并将在其上调用openEditor。

#2


2  

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.

在我看来,最好的方法是创建一个简单的Eclipse插件,显示您的视图。 Eclipse有一个非常好的API,并且有很多文档。根据我实现Eclipse插件的经验,您不需要成为一个优秀的GUI设计器,因为大多数控件都是编写的,您可以重用它。

If you decide to take this way, here are some resources to start:

如果你决定采取这种方式,这里有一些资源可以开始:

  • Creating a minimal Eclipse plugin
  • 创建一个最小的Eclipse插件

  • Implementing a simple view with context menu.
  • 使用上下文菜单实现简单视图。

  • Understanding Eclipse viewers
  • 了解Eclipse查看器

Hope it helps.

希望能帮助到你。

#1


1  

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.

我自己没有尝试过,但我想通过一些技巧,可以在JUNit视图中自动打开格式正确的文件。

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.

我认为对org.eclipse.ui.ide.IDE.openEditor(IWorkbenchPage,URI,String,boolean)的调用应该有效。这是因为JUnit格式的xml文件设置为使用JUnit视图打开。

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.

在开始这一点之前,您需要创建一个Eclipse插件。这将是一个简单的插件,它将有一个类将监听测试框架的运行完成,另一个类将知道在哪里找到生成的xml文件并将在其上调用openEditor。

#2


2  

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.

在我看来,最好的方法是创建一个简单的Eclipse插件,显示您的视图。 Eclipse有一个非常好的API,并且有很多文档。根据我实现Eclipse插件的经验,您不需要成为一个优秀的GUI设计器,因为大多数控件都是编写的,您可以重用它。

If you decide to take this way, here are some resources to start:

如果你决定采取这种方式,这里有一些资源可以开始:

  • Creating a minimal Eclipse plugin
  • 创建一个最小的Eclipse插件

  • Implementing a simple view with context menu.
  • 使用上下文菜单实现简单视图。

  • Understanding Eclipse viewers
  • 了解Eclipse查看器

Hope it helps.

希望能帮助到你。