Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » independent test problem(independent test makes following tests fail if started first)
independent test problem [message #682171] Fri, 10 June 2011 14:49 Go to next message
fan Missing name is currently offline fan Missing nameFriend
Messages: 7
Registered: June 2011
Junior Member
Hello I wrote a test for checking a Wizard and his Back-button of a normal Eclipse Wizard.

This Test runs fine if I use it somewhere in the workflow. But when it is started first, the follwing tests, who all start with

Bot.menu("File").menu("New").menu("Project").click();

,fail. I always get a WidgetNotFoundException on the .menu("File") .

The aktive Shell after the test is the Eclipse shell, so that should not be the problem.

I wrote some classes to interact with buttons, comboboxes and other widgets, but I think the following metho is still understandable without knowing this classes:



public static void backAndNextButtonTest (SWTWorkbenchBot bot ){

bot.menu("File").menu("New").menu("Project").click();

findTCPWShell(bot);

String testName = "Project1";
String testLocation ="c:\\test";

Button next = Button.getButtonByTitle(wizBot,NEXT_BUT_TEXT);
Button finish = Button.getButtonByTitle(wizBot,FINISH_BUT_TEXT);
Button back = Button.getButtonByTitle(wizBot,BACK_BUT_TEXT);
Button cancel = Button.getButtonByTitle(wizBot,CANCEL_BUTTON_TEXT);
Textfield textProName = Textfield.getTextByLabel(wizBot,PROJECT_NAME_TEXTFIELD_LABEL );
Textfield textLoc = Textfield.getTextByLabel(wizBot,LOCATION_TEXTFIELD_LABEL );
CheckBox useDefaultCheckBox = CheckBox.getCheckBoxByLabel(wizBot, DEFAULT_LOCATION_CHECKBOX_LABEL);

textProName.setText(testName);
useDefaultCheckBox.UnCheck();
textLoc.setText(testLocation);

next.clickButton();

SWTBotShell confirmShell=null;
try{
confirmShell = wizBot.shell(CONFIRM_SHELL_LABEL);
}catch (WidgetNotFoundException e)
{
//do nothing , location already created
}
if ( null != confirmShell )
{
Button.getButtonByTitle(wizBot, CONFIRM_SHELL_OK_BUT_TEXT).clickButton();
wizBot.waitUntil(Conditions.shellCloses(confirmShell));
}
//NEXT PAGE : doing settings -> using BACK Button //

CheckBox ldfModelCheckBox = CheckBox.getCheckBoxByLabel(wizBot, LDF_MODEL_CHECKBOX_LABEL);
assertTrue (ldfModelCheckBox.isChecked());

SWTBotCombo langBox = TCPWShell.bot().comboBox(LANGUAGE_COMBO_SHOWN_OPTION);
langBox.setSelection("xxx");
SWTBotCombo typBox = TCPWShell.bot().comboBox(TYP_COMBO_SHOWN_OTPION);
typBox.setSelection("xxx");
SWTBotCombo hardWBox = TCPWShell.bot().comboBox( HARDWARE_COMBO_SHOWN_OPTION);
hardWBox.setSelection("xxx");

ldfModelCheckBox.UnCheck();

back.clickButton();

//PREVIOUS PAGE : checking settings -> using NEXT Button//

assertTrue ( textLoc.getText().trim().equals(testLocation));
assertTrue ( textProName.getText().trim().equals(testName));
assertTrue ( useDefaultCheckBox.isUnChecked());

assertTrue(back.isDisabled() && next.isEnabled() && finish.isDisabled() && cancel.isEnabled());

next.clickButton();

// NEXT PAGE : checking settings //

assertTrue(back.isEnabled() && next.isDisabled() && finish.isEnabled() && cancel.isEnabled());

assertTrue (langBox.getText().equals("xxx"));
assertTrue (typBox.getText().equals("xxx"));
assertTrue (hardWBox.getText().equals("xxx"));

cancel.clickButton();

wizBot.waitUntil(Conditions.shellCloses(TCPWShell)) ;

removeLocation(testLocation);

}

private static void findTCPWShell (SWTWorkbenchBot bot ) {
wizBot = bot;
wizBot.waitUntil(Conditions.waitForShell(TCPWmatcher));
TCPWShell = new SWTBotShell ((Shell) wizBot.widget(TCPWmatcher));
assertTrue(TCPWShell.isActive());
}

I also get the following Failure messages, but i am not sure if they have anything to do with this Problem :


org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.core.runtime.AssertionFailedException: null argument:)
at org.eclipse.swt.SWT.error(SWT.java:4083)
at org.eclipse.swt.SWT.error(SWT.java:3998)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.swtbot.eclipse.core.UITestApplication.start(UITestApplication.java:54)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
at org.eclipse.jface.viewers.StructuredSelection.<init>(StructuredSelection.java:74)
at com.rt.hightec.framework.buildsystem.action.ChangeBuildConfigBuildAction.fillMenu(Unknown Source)
at org.eclipse.cdt.ui.actions.ChangeBuildConfigMenuAction$1.menuShown(ChangeBuildConfigMenuAction.java:98)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:241)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder.findMenusInternal(MenuFinder.java:152)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder.findMenusInternal(MenuFinder.java:161)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder.findMenusInternal(MenuFinder.java:161)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder.access$0(MenuFinder.java:149)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder$2.run(MenuFinder.java:124)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder$2.run(MenuFinder.java:1)
at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$2.doRun(UIThreadRunnable.java:140)
at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$1.run(UIThreadRunnable.java:89)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
... 24 more
Re: independent test problem [message #687868 is a reply to message #682171] Thu, 23 June 2011 12:26 Go to previous messageGo to next message
Benjamin Ratiarisolo is currently offline Benjamin RatiarisoloFriend
Messages: 16
Registered: January 2010
Location: Paris, France
Junior Member
Hi fan,

I did struggle with top level workbench menu items which randomly seemed . After investigating a few screen-shots I realized that they were grayed, i.e. disabled. Thus I ended up wrapping my code to access those with the below snippet to make sure the top-level shell was indeed activated:

SWTWorkbenchBot bot = ...;
String shellText = bot.shells()[0].getText();
bot.waitUntil(Conditions.shellIsActive(shellText));
SWTBotShell swtBotShell = bot.shell(shellText);
swtBotShell.activate();

I am not sure this is related to your issue though.
You can give a it a try.


--
Benjamin Ratiarisolo
IBM ODM Decision Server Rules - Software Developer
IBM Software - France Lab
Re: independent test problem [message #722317 is a reply to message #682171] Mon, 05 September 2011 11:17 Go to previous messageGo to next message
Nastya Lagunova is currently offline Nastya LagunovaFriend
Messages: 2
Registered: August 2011
Junior Member
fan wrote on Fri, 10 June 2011 10:49
Hello I wrote a test for checking a Wizard and his Back-button of a normal Eclipse Wizard.

This Test runs fine if I use it somewhere in the workflow. But when it is started first, the follwing tests, who all start with

Bot.menu("File").menu("New").menu("Project").click();

,fail. I always get a WidgetNotFoundException on the .menu("File") .



We have a perfect solution that ensures that your tests would run independently, however, it involves trying another testing tool.
Re: independent test problem [message #780499 is a reply to message #682171] Wed, 18 January 2012 10:44 Go to previous message
fan Missing name is currently offline fan Missing nameFriend
Messages: 7
Registered: June 2011
Junior Member
The problem is solved in the thread :

Can't access main "Project" menu after selecting project in view




[Updated on: Wed, 18 January 2012 11:35]

Report message to a moderator

Previous Topic:method to select a menuItem object for opening Properties window of a project
Next Topic:web service explorer
Goto Forum:
  


Current Time: Wed Apr 24 15:56:26 GMT 2024

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

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

Back to the top