Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [databinding] JUnit tests, howto ?
[databinding] JUnit tests, howto ? [message #658044] Sat, 05 March 2011 08:20 Go to next message
Marco Maccaferri is currently offline Marco Maccaferri
Messages: 132
Registered: July 2009
Senior Member
Ho do you run JUnit tests with databinding ?
I can't find a way to set the default realm so every attempt to bind
widgets fails with an exception. How do you test databinding ?

Regards,
Marco.
Re: [databinding] JUnit tests, howto ? [message #658156 is a reply to message #658044] Mon, 07 March 2011 03:14 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5296
Registered: July 2009
Senior Member
The default realm is in RCP created by workbench for you so you need to
do it in your JUnit-Tests your own.

My JUnit code looks like this:

public void testA() {

Realm.runWithDefault(SWTObservables.getRealm(Display.getCurr ent()),new
Runnable() {
public void run() {
_testA();
}
});
}

private void _testA() {
// Real tests
}

Tom

Am 05.03.11 14:20, schrieb Marco Maccaferri:
> Ho do you run JUnit tests with databinding ?
> I can't find a way to set the default realm so every attempt to bind
> widgets fails with an exception. How do you test databinding ?
>
> Regards,
> Marco.
Re: [databinding] JUnit tests, howto ? [message #658234 is a reply to message #658156] Mon, 07 March 2011 09:16 Go to previous messageGo to next message
Marco Maccaferri is currently offline Marco Maccaferri
Messages: 132
Registered: July 2009
Senior Member
On 07/03/2011 09:14 Tom Schindl ha scritto:

> The default realm is in RCP created by workbench for you so you need to
> do it in your JUnit-Tests your own.

Yes, I was hoping to find a ready to use solution.

I wrote a simple TestCase subclass that overrides the run(TestResult)
method:

public class DatabindingTestCase extends TestCase {

@Override
public void run(final TestResult result) {

Realm.runWithDefault(SWTObservables.getRealm(Display.getDefa ult()), new
Runnable() {

@Override
public void run() {
DatabindingTestCase.super.run(result);
}
});
}
}

If you derive the tests from that class they should all run with the
default Realm set without other changes. Looks to work right so far.

Regards,
Marco.
Re: [databinding] JUnit tests, howto ? [message #658237 is a reply to message #658234] Mon, 07 March 2011 09:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5296
Registered: July 2009
Senior Member
Hi Marco,

In CVS you should a find a bunch of databinding tests and my wild guess
is that they all derive from such a base class too.

Tom

Am 07.03.11 15:16, schrieb Marco Maccaferri:
> On 07/03/2011 09:14 Tom Schindl ha scritto:
>
>> The default realm is in RCP created by workbench for you so you need to
>> do it in your JUnit-Tests your own.
>
> Yes, I was hoping to find a ready to use solution.
>
> I wrote a simple TestCase subclass that overrides the run(TestResult)
> method:
>
> public class DatabindingTestCase extends TestCase {
>
> @Override
> public void run(final TestResult result) {
>
> Realm.runWithDefault(SWTObservables.getRealm(Display.getDefa ult()), new
> Runnable() {
>
> @Override
> public void run() {
> DatabindingTestCase.super.run(result);
> }
> });
> }
> }
>
> If you derive the tests from that class they should all run with the
> default Realm set without other changes. Looks to work right so far.
>
> Regards,
> Marco.
Re: [databinding] JUnit tests, howto ? [message #659927 is a reply to message #658237] Wed, 16 March 2011 04:24 Go to previous message
budili Missing name is currently offline budili Missing name
Messages: 64
Registered: May 2010
Member
Here is a nice description for the Realm setup and Unit-Tests.
Previous Topic:Display Class Dispose method
Next Topic:Missing minimize, maximize buttons in Dialog on Linux
Goto Forum:
  


Current Time: Mon Sep 01 17:05:51 EDT 2014

Powered by FUDForum. Page generated in 0.02098 seconds