Skip to main content



      Home
Home » Newcomers » Newcomers » Null Display.getCurrent when running JUnit4/Swt/JFace tests?
Null Display.getCurrent when running JUnit4/Swt/JFace tests? [message #249987] Sat, 23 February 2008 16:57 Go to next message
Eclipse UserFriend
Originally posted by: no.ddress.now

First efforts to develop unit tests using Eclipse 3.4M4 & JUnit4 for an
SWT/JFace stand-alone library.

The JFace dependency is to org.eclipse.jface.resource.ImageRegistry.
In the setup for one unit test, I have:

@Before
public void setUp() throws Exception {
...
imageRegistry = new ImageRegistry();
...

The ImageRegistry constructor invokes Display.getCurrent(), which
returns null, and the dependent unit test fails.

Is something required to force the unit test to run on the UI thread?
Re: Null Display.getCurrent when running JUnit4/Swt/JFace tests? [message #250017 is a reply to message #249987] Sun, 24 February 2008 08:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Gbr,

From code inspection, it just looks like you need to create a Display
and as a side effect that will register it on the thread that creates
it. I guess you should do that in your setup code. I expect it's also
possible to run your JUnit as an Eclipse application that would
automatically create the display...


Gbr wrote:
> First efforts to develop unit tests using Eclipse 3.4M4 & JUnit4 for an
> SWT/JFace stand-alone library.
>
> The JFace dependency is to org.eclipse.jface.resource.ImageRegistry.
> In the setup for one unit test, I have:
>
> @Before
> public void setUp() throws Exception {
> ...
> imageRegistry = new ImageRegistry();
> ...
>
> The ImageRegistry constructor invokes Display.getCurrent(), which
> returns null, and the dependent unit test fails.
>
> Is something required to force the unit test to run on the UI thread?
>
Re: Null Display.getCurrent when running JUnit4/Swt/JFace tests? [message #250043 is a reply to message #250017] Sun, 24 February 2008 14:31 Go to previous message
Eclipse UserFriend
Originally posted by: no.ddress.now

In article <fprr73$pj0$1@build.eclipse.org>, merks@ca.ibm.com says...
> it just looks like you need to create a Display
> and as a side effect that will register it on the thread that creates
> it.

Yep, that works. Thanks.
Previous Topic:J2EE runtime directory
Next Topic:Help with importing a class
Goto Forum:
  


Current Time: Fri Jul 18 05:50:50 EDT 2025

Powered by FUDForum. Page generated in 0.20594 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top