Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » SWTBot tests do not work with maven, but with Eclipse (Shell does not close)
SWTBot tests do not work with maven, but with Eclipse [message #1784920] Thu, 05 April 2018 18:39 Go to next message
Robert Hilbrich is currently offline Robert HilbrichFriend
Messages: 12
Registered: April 2018
Location: Berlin
Junior Member

I am still trying to get a proper SWTBot test running. Everything is fine on my local machine, but the test fails (runs in timeout) on Travis.

The test is simple:
@Test
  public void createNewProject() {
    BasicTests.bot.menu("File").menu("New Project").click();
    final SWTBotShell newProjectShell = BasicTests.bot.shell("New ASSIST Project").activate();
    final SWTBot newProjectShellBot = newProjectShell.bot();
    newProjectShellBot.textWithLabel("&Project name:").setText("ExampleProject");
    newProjectShellBot.waitUntil(new DefaultCondition() {
      @Override
      public String getFailureMessage() {
        return "unable to select";
      }
      @Override
      public boolean test() {
        return newProjectShellBot.button("Finish").isEnabled();
      }
    });
    newProjectShellBot.button("Finish").click();
    BasicTests.bot.waitUntil(Conditions.shellCloses(newProjectShell), 20000);
  }

(see [1])

The error log is also pretty short:
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running ch.hilbri.assist.gui.tests.TestSuiteAllGUITests
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 24.755 sec <<< FAILURE! - in ch.hilbri.assist.gui.tests.TestSuiteAllGUITests
checkAboutBox(ch.hilbri.assist.gui.tests.basics.BasicTests)  Time elapsed: 0.363 sec
createNewProject(ch.hilbri.assist.gui.tests.basics.BasicTests)  Time elapsed: 21.969 sec  <<< ERROR!
org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 20000 ms.: The shell Shell with text {New ASSIST Project} did not close.
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:522)
	at org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot.waitUntil(SWTWorkbenchBot.java:1)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:496)
	at org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot.waitUntil(SWTWorkbenchBot.java:1)
	at ch.hilbri.assist.gui.tests.basics.BasicTests.createNewProject(BasicTests.java:43)

(see [2], line 43 corresponds to the waitUntil condition).

Do you have any idea, why the shell closes on my local machine just fine, but not on travis? Even with a timeout of 20s?

Thank you for any insight.

Robert

[1]: https://github.com/RobertHilbrich/assist-public/blob/master/ch.hilbri.assist.gui.tests/src/ch/hilbri/assist/gui/tests/basics/BasicTests.xtend
(yes, I write in Xtend, but you can see the compiled version above)
[2]: https://travis-ci.org/RobertHilbrich/assist-public

[Updated on: Fri, 06 April 2018 18:04]

Report message to a moderator

Re: SWTBot tests do not work with maven, but with Eclipse [message #1784995 is a reply to message #1784920] Fri, 06 April 2018 18:11 Go to previous messageGo to next message
Robert Hilbrich is currently offline Robert HilbrichFriend
Messages: 12
Registered: April 2018
Location: Berlin
Junior Member

I tried to replicate this setup locally. I installed debian stable and Eclipse Oxygen.3. My results:

    1. Cloning my repository and triggering the SWTBot tests with the SWTBot launcher from within Eclipse IDE works fine. All tests work as expected.
    2. Cloning the repository on the command line (git clone --recursive https://github.com/roberthilbrich/assist-public) and executing "mvn clean verify" to trigger the tests leads to the shell not being closed during the tests.

I am not sure, where the differences between these two approaches may be. I ensured that the surefire settings in the pom.xml are the same as recommended in the SWTBot wiki.

So this issue is NOT travis related. I am using XFCE (where it fails) and travis uses metacity.

Do you have an idea, what could cause the different behaviour? Is there any workaround I could apply?

Best,
Robert
Re: SWTBot tests do not work with maven, but with Eclipse [message #1785123 is a reply to message #1784995] Mon, 09 April 2018 18:23 Go to previous message
Robert Hilbrich is currently offline Robert HilbrichFriend
Messages: 12
Registered: April 2018
Location: Berlin
Junior Member

Sorry for all the fuss. I got to the root cause of this issue and fixed it. It was not the fault of SWTbot. Instead my maven surefire plugin was missing some dependencies. Due to these missing dependencies, the performFinish method of the Wizard failed with an exception that was not caught properly. That is the reason, why the dialog did not close during the ui test.
Previous Topic:SWTBot and E4 RCP Applications - Status?
Next Topic:How to make the Logger snippet work
Goto Forum:
  


Current Time: Wed Sep 19 03:13:19 GMT 2018

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

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

Back to the top