How to run UI tests on server (on a server without a window manager activated by default)

Blog Categories: 

I'm currently trying to move GMF-Runtime build to Tycho (following GMF-Tooling). I asked for a job on the server for this new fast and simple build but I encountered an issue. And I found a solution. 

The issue

GMF is a graphical framework, so there are User Interface tests. Unfortunately,  they failed with the following error - which you can find in .log of the workspace/.metadata folder - when you run any test on the eclipse server:

[cc] org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed] at org.eclipse.swt.SWT.error( at org.eclipse.swt.widgets.Display.createDisplay( at org.eclipse.swt.widgets.Display.create( at at org.eclipse.swt.widgets.Display.( at org.eclipse.swt.widgets.Display.( at org.eclipse.ui.internal.Workbench.createDisplay( at org.eclipse.ui.PlatformUI.createDisplay( at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay( at org.eclipse.ui.internal.ide.application.IDEApplication.start( at org.eclipse.tycho.surefire.osgibooter.UITestApplication.runApplication( at at org.eclipse.tycho.surefire.osgibooter.UITestApplication.start( at at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication( at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start( at at at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke( at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( at org.eclipse.equinox.launcher.Main.invokeFramework( at org.eclipse.equinox.launcher.Main.basicRun( at at org.eclipse.equinox.launcher.Main.main( [/cc]

The solution

I spent some time on Google and found the solution... in several chunks. So I put them together to provide the solution here in a single piece:

  • Check Run Xvnc during build (and don't bother to check take screenshot, it doesn't work)

- Add an Execute shell build action before launching your tests with metacity --replace --sm-disable & :

Simple but it's all in one place. Hope it will help you.

And - talking about help - any help on understanding why these three GMF tests are still failing is very welcome.