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);
}
}
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?
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):
Eclipse and create a new workspace somewhere on the discworkspaceEclipse instance which holds the Plug-in Test codeJUnit Plug-in Test Launch Configuration, go to the Main tab
workspace created in 1) and populated in 2)workspace and all projects in itIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With