Skip to main content


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 13:20 Go to next message
Marco Maccaferri is currently offline Marco MaccaferriFriend
Messages: 147
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 08:14 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
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 14:16 Go to previous messageGo to next message
Marco Maccaferri is currently offline Marco MaccaferriFriend
Messages: 147
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 14:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
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 08:24 Go to previous message
budili Missing name is currently offline budili Missing nameFriend
Messages: 64
Registered: May 2010
Member
Here is a nice description for the Realm setup and Unit-Tests.
Previous Topic:DataBinding for a combobox which holds a Elist from a model
Next Topic:Custom "theme" for MenuManager?
Goto Forum:
  


Current Time: Fri Apr 26 02:23:54 GMT 2024

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

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

Back to the top