Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Migrating Tests from 1.5 to 2.0
Migrating Tests from 1.5 to 2.0 [message #1466873] Sun, 09 November 2014 15:51 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi RAP team,

We're in the process of migrating our code base from RAP 1.5 to 2.0.

One part that needs adjustments is the way we run our tests.

As we understand in 2.0 we don't need RAP JUnit test to run our tests
instead we can use plain JUnit

To prove it we run a very small test below which always fails:

public class TestComposite
{
private Display display;
private Shell shell;

@Before
public void setUp() throws Exception
{
Fixture.setUp();
Fixture.fakePhase(PhaseId.PROCESS_ACTION);
display = new Display();
shell = new Shell(display, SWT.NONE);
}

@After
public void tearDown() throws Exception {Fixture.tearDown();}

@Test
public void testSelectionAdapterInvocation() throws Exception
{
Button button = new Button(shell, SWT.CHECK);

SelectionListener listener = mock(SelectionListener.class);
button.addSelectionListener(listener);

shell.open();
button.setSelection(true);
verify(listener).widgetSelected(any(SelectionEvent.class));
shell.close();
}
}

Do we miss something ?

Any help would be greatly appreciated.

Thanks & Regards,
Setya
Re: Migrating Tests from 1.5 to 2.0 [message #1473977 is a reply to message #1466873] Sat, 15 November 2014 03:04 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Team,

Anyone can reproduce the problem ?

Regards,
Setya


On 11/09/2014 10:51 PM, Setya wrote:
> Hi RAP team,
>
> We're in the process of migrating our code base from RAP 1.5 to 2.0.
>
> One part that needs adjustments is the way we run our tests.
>
> As we understand in 2.0 we don't need RAP JUnit test to run our tests
> instead we can use plain JUnit
>
> To prove it we run a very small test below which always fails:
>
> public class TestComposite
> {
> private Display display;
> private Shell shell;
>
> @Before
> public void setUp() throws Exception
> {
> Fixture.setUp();
> Fixture.fakePhase(PhaseId.PROCESS_ACTION);
> display = new Display();
> shell = new Shell(display, SWT.NONE);
> }
>
> @After
> public void tearDown() throws Exception {Fixture.tearDown();}
>
> @Test
> public void testSelectionAdapterInvocation() throws Exception
> {
> Button button = new Button(shell, SWT.CHECK);
>
> SelectionListener listener = mock(SelectionListener.class);
> button.addSelectionListener(listener);
>
> shell.open();
> button.setSelection(true);
> verify(listener).widgetSelected(any(SelectionEvent.class));
> shell.close();
> }
> }
>
> Do we miss something ?
>
> Any help would be greatly appreciated.
>
> Thanks & Regards,
> Setya
Re: Migrating Tests from 1.5 to 2.0 [message #1474239 is a reply to message #1473977] Sat, 15 November 2014 08:17 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Setya,
setting button CHECK/RADIO button selection by code does not trigger the
selection listener in SWT/RWT. If you want to simulate user action try:
---
Fixture.fakeNotifyOperation( WidgetUtil.getId( button ),
ClientMessageConst.EVENT_SELECTION, null );
Fixture.readDataAndProcessAction( button );
---
All RWT tests (org.eclipse.rap.rwt.test bundle with 7000+ tests) are
plain JUnit tests and they are working without problem.
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Nebula Grid missing GridTableViewer and GridTreeViewer
Next Topic:Relative width of elements / page
Goto Forum:
  


Current Time: Fri Apr 26 23:55:20 GMT 2024

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

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

Back to the top