使用随附的工作区项目运行Eclipse插件测试 [英] Run Eclipse Plug-in Test with included workspace projects

查看:86
本文介绍了使用随附的工作区项目运行Eclipse插件测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个小型Eclipse插件并为此进行一些测试.我通过指定插件在Headless Mode中运行来启动插件测试.我想在那些测试中访问工作空间中的活动Java项目,但是当我执行它们时,工作空间为空.我使用以下代码来获取所有Java项目(效果很好):

I'm writing a small Eclipse plug-in and some tests for it. I'm starting the plug-in tests by specifying them to run in Headless Mode. I want to access the active Java projects within the workspace in those tests, but when I execute them, the workspace is empty. I use the following code to get all Java projects (which works fine):

IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
for(IProject project : myWorkspaceRoot.getProjects()) {
        if(project.isOpen() && isJavaProject(project)) {
                IJavaProject javaProject = JavaCore.create(project);
                projects.put(project.getName(), javaProject);
        }
}

但是,项目始终为空.这是因为Headless Mode我猜想使用空工作空间启动了一个新的Eclipse实例.我的问题是:我可以以某种方式指定测试应该在当前的Eclipse实例中运行,还是可以指定想要在新创建的工作空间中拥有的项目?

However, the projects are always empty. This is due to the fact that the Headless Mode starts a new Eclipse instance with an empty workspace I guess. My question is: can I somehow either specify that the tests should run in the current Eclipse instance OR can I specify the projects I want to have in the newly created workspace?

推荐答案

我想出一种简单的方法来设置测试workspace,并希望与您共享(即使这意味着回答我自己的问题):

I figured out an easy way to setup a test workspace and wanted to share it with you (even though this means answering my own question):

  1. 打开Eclipse并在光盘上的某个地方创建一个新的workspace
  2. 将一些示例项目添加到新的workspace
  3. 打开一个包含Plug-in Test代码的Eclipse实例
  4. JUnit Plug-in Test Launch Configuration中,转到Main选项卡
  1. Open Eclipse and create a new workspace somewhere on the disc
  2. Add some sample projects to the new workspace
  3. Open an Eclipse instance which holds the Plug-in Test code
  4. In the JUnit Plug-in Test Launch Configuration, go to the Main tab

  1. 指定在 1)中创建并在 2)
  2. 中填充的workspace
  3. 运行测试,测试将从指定的workspace及其中的所有项目开始
  1. Specify the workspace created in 1) and populated in 2)
  2. Run the test, which will start with the specified workspace and all projects in it

这篇关于使用随附的工作区项目运行Eclipse插件测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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