Hi Mickael, If test don't create display, you can't run them quickly in Eclipse by using Run as -> JUnit test. (no need to start an RCP application). This is useful for widgets which are only based on SWT.
The method I described allows tests to run successfully in every case (tests don't create a display if an application did it already). You're totally right for testing RCP applications/ : tests shouldn't create display in that case. -- Nicolas Le 24 févr. 2012 à 10:33, Mickael Istria a écrit : > Hi, > > On 02/24/2012 10:21 AM, Nicolas Richeton wrote: >> >> The trick is to get the current display (display.getcurrent()) . If current >> display is null, create a new one. >> Cdatetime uses cwt as base test. Try to patch VTestCase this way. I hope >> this will fix a lot of tests. > I think tests should never create a Display, it is the responsability of the > application that runs tests to create and manage one. In our case, the Tycho > test runner has option <useUIHarness> set to true > (http://git.eclipse.org/c/nebula/org.eclipse.nebula.git/tree/releng/org.eclipse.nebula.nebula-parent/pom.xml > ), which means that a display is created. > You can get it Display using Display.getDefault(). > > If your test in intended to run in UIThread -to avoid Display.asyncExec(...)- > then you should override in the pom.xml for your tests the configuration of > the tycho-surefire-plugin, and add to is an <useUIThread>true</useUIThread> > option. > > HTH, > -- > Mickael Istria > Eclipse developer at JBoss, by Red Hat > My blog - My Tweets > _______________________________________________ > nebula-dev mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/nebula-dev
_______________________________________________ nebula-dev mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/nebula-dev
