Simple test - fails on closing RCP app.

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Simple test - fails on closing RCP app.

Postby patricka » Tue Apr 19, 2011 8:48 am

Have used the ContactManagerRCP to do a simple test ---- start the application and close the application.... (and failed (hand in face))

It's failing on the line........

ui.ensureThat(new ShellLocator("RCP Contacts Editor").isClosed());


Don't understand why.....noticed something similar on this forum but never went on to provide how to fix.


I also noticed by accident that if I run it as a 'org.eclipse.platform.ide' in the run config bit --- it passes ----- but if I run it as the actual rcp product it fails (this might be a red herring?)

Any help appreciated.

Error log and full code (minus import statements) below.


!ENTRY com.instantiations.eclipse 1 0 2011-04-19 17:33:50.453
!MESSAGE WindowTester: 201009131510 - win32,win32,x86
Exception in thread "WorkbenchTestable" org.eclipse.swt.SWTException: Device is disposed
at org.eclipse.swt.SWT.error(SWT.java:4083)
at org.eclipse.swt.SWT.error(SWT.java:3998)
at org.eclipse.swt.SWT.error(SWT.java:3969)
at org.eclipse.swt.widgets.Display.error(Display.java:1249)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4581)
at org.eclipse.ui.internal.testing.WorkbenchTestable.testingFinished(WorkbenchTestable.java:122)
at org.eclipse.pde.internal.junit.runtime.UITestApplication.runTests(UITestApplication.java:120)
at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:71)
at java.lang.Thread.run(Unknown Source)

public class test1 extends UITestCaseSWT {

/* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
IUIContext ui = getUI();
ui.ensureThat(new WorkbenchLocator().hasFocus());
ui.ensureThat(ViewLocator.forName("Welcome").isClosed());
ui.ensureThat(new WorkbenchLocator().isMaximized());
}

/**
* Main test method.
*/
public void testtest1() throws Exception {
IUIContext ui = getUI();
ui.ensureThat(new ShellLocator("RCP Contacts Editor").isClosed());
ui.wait(new ShellDisposedCondition("RCP Contacts Editor"));
}

}
patricka
 
Posts: 2
Joined: Tue Apr 19, 2011 8:39 am

Re: Simple test - fails on closing RCP app.

Postby gnebling » Tue Apr 19, 2011 11:06 am

You can remove the last two lines of code and it should work. The framework automatically closes the application before exit so the call to close the app is redundant.

/**
* Main test method.
*/
public void testtest1() throws Exception {
IUIContext ui = getUI();
//remove these two lines
//ui.ensureThat(new ShellLocator("RCP Contacts Editor").isClosed());
//ui.wait(new ShellDisposedCondition("RCP Contacts Editor"));
}
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Re: Simple test - fails on closing RCP app.

Postby patricka » Tue Apr 19, 2011 1:13 pm

thanks --- i did do that too but felt a bit like cheating --- why would the recorder write the lines of code in the first place ?
patricka
 
Posts: 2
Joined: Tue Apr 19, 2011 8:39 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest

cron