Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » SWTBot and E4 RCP Applications - Status?(How to combine E4 RCP Applications and SWTBot for GUI testing?)
SWTBot and E4 RCP Applications - Status? [message #1784667] Sun, 01 April 2018 18:10 Go to next message
Robert Hilbrich is currently offline Robert HilbrichFriend
Messages: 24
Registered: April 2018
Location: Berlin
Junior Member

For my E4 RCP application, I am trying to add ui tests in addition to my functional tests - but I have trouble getting the setup right. I am using Eclipse Oxygen.3 (4.7.3) on OSX High Sierra and SWTBot 2.6.0.201706141832.

I followed the explanations from Lars Vogel [1] to create a plugin for my tests and create a minimal test. I also followed his instructions to create a launch configuration. In order to have at least a launch, I had to add org.eclipse.equinox.launcher as a dependency to my MANIFEST.MF.

My applications opens up, but it does not seem to reach the test, because in the console view, I get a lot of error messages (see attachment).

Could you please give me a pointer to some information on the current status of SWTBot and E4. How do I get this combination working?

My code is entirely public. The entire application is available here [2]. The plugin with the SWTbot tests is here [3]. You can also find the launch configuration in [3].

Thanks a lot for your time,
Robert


[1]: vogella.com / tutorials / SWTBot / article.html - Section 6

[2]: github: roberthilbrich / assist-public

[3]: github: roberthilbrich / assist-public / tree / master / ch.hilbri.assist.gui.tests
  • Attachment: console.log
    (Size: 8.66KB, Downloaded 132 times)
Re: SWTBot and E4 RCP Applications - Status? [message #1784766 is a reply to message #1784667] Tue, 03 April 2018 18:45 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

Quote:

***WARNING: Display must be created on main thread due to Cocoa restrictions.


You need to launch your JVM with `-XstartOnFirstThread`. You put this in the VM Arguments section on the Arguments tab of your launch configuration. Since Oxygen (I think), launch configurations have a new option in the Arguments tab to automatically pass this flag when launching with SWT.

Brian.
Re: SWTBot and E4 RCP Applications - Status? [message #1784767 is a reply to message #1784766] Tue, 03 April 2018 19:07 Go to previous messageGo to next message
Robert Hilbrich is currently offline Robert HilbrichFriend
Messages: 24
Registered: April 2018
Location: Berlin
Junior Member

Yes, this option is enabled. I also added the option the vm arguments - but unfortunately, there is no change. I attached the launcher file (see below).

My feeling is, that there is something happening with junit - maybe some version incompatibility?! I enabled *all* plugins from my eclipse installation (target plugins). Could it be, that is picking up on another junit in my oxygen installation?

Best,

Robert


Launcher:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<booleanAttribute key="askclear" value="false"/>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="true"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="true"/>
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/ch.hilbri.assist.gui.tests/src/ch/hilbri/assist/gui/tests/SimpleTests.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="ch.hilbri.assist.gui.tests.SimpleTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="ch.hilbri.assist.gui.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -XstartOnFirstThread"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="ch.hilbri.assist.gui.product"/>
<booleanAttribute key="run_in_ui_thread" value="false"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="true"/>
</launchConfiguration>

Re: SWTBot and E4 RCP Applications - Status? [message #1784829 is a reply to message #1784767] Wed, 04 April 2018 13:50 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

So I checked out your project and was able to run the simple tests -- I saw a workbench open up, and then disappear. The Mylyn CommonColors exception is bug 529862 but is unrelated to your problem.

From the JUnit4TestLoader class-cast exception, my guess is that your IDE has multiple versions of several bundles available, and some incompatible versions are being wired up.
Exception in thread "Plug-in Tests Runner" java.lang.IllegalArgumentException: Error: test loader org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader not found:
java.lang.ClassCastException: org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader cannot be cast to org.eclipse.jdt.internal.junit.runner.ITestLoader
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:367)


My suggestion would be to create a Target Definition and explicitly select your dependencies. That should provide a bit more control and help avoid having multiple versions of bundles. That will also help other developers who seek to contribute to developing your tools.

Brian.
Re: SWTBot and E4 RCP Applications - Status? [message #1784852 is a reply to message #1784829] Wed, 04 April 2018 20:00 Go to previous messageGo to next message
Robert Hilbrich is currently offline Robert HilbrichFriend
Messages: 24
Registered: April 2018
Location: Berlin
Junior Member

Thanks for the tip with the target definition. I followed your recommendation and added a target definition to my projects (and POM files) - see [1]. This greatly reduced the size of the log (see [2]). But unfortunately, the casting error remains. Furthermore, I do not believe, that the tests are actually running, because:
1. The "Junit Test View" does not report that any test has run
2. This dummy test [3] does not fail - but it should.

What could I try next?

[1]: https://github.com/RobertHilbrich/assist-public/blob/master/ch.hilbri.assist.releng.product.gui.target/ch.hilbri.assist.releng.product.gui.target

[2]:
!SESSION 2018-04-04 21:55:37.136 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_131
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=de_DE
Framework arguments:  -version 3 -port 51786 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames ch.hilbri.assist.gui.tests.SimpleTests -application org.eclipse.pde.junit.runtime.nonuithreadtestapplication -product ch.hilbri.assist.gui.product -testpluginname ch.hilbri.assist.gui
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -consoleLog -version 3 -port 51786 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames ch.hilbri.assist.gui.tests.SimpleTests -application org.eclipse.pde.junit.runtime.nonuithreadtestapplication -product ch.hilbri.assist.gui.product -data /Users/robert/Eclipse-Workspaces/ASSIST-Public-Oxygen/../junit-workspace -dev file:/Users/robert/Eclipse-Workspaces/ASSIST-Public-Oxygen/.metadata/.plugins/org.eclipse.pde.core/pde-junit/dev.properties -os macosx -ws cocoa -arch x86_64 -consoleLog -testpluginname ch.hilbri.assist.gui

!ENTRY org.eclipse.e4.ui.workbench 2 0 2018-04-04 21:55:39.474
!MESSAGE No binding context exists for org.eclipse.ui.contexts.dialog
Exception in thread "Plug-in Tests Runner" java.lang.IllegalArgumentException: Error: test loader org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader not found:
java.lang.ClassCastException: org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader cannot be cast to org.eclipse.jdt.internal.junit.runner.ITestLoader
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:367)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:362)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:306)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.init(RemotePluginTestRunner.java:244)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:174)
	at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.lambda$0(PlatformUITestHarness.java:43)
	at java.lang.Thread.run(Thread.java:748)

	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:372)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:362)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:306)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.init(RemotePluginTestRunner.java:244)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:174)
	at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.lambda$0(PlatformUITestHarness.java:43)
	at java.lang.Thread.run(Thread.java:748)


[3]:
    
    @Test
    public void executeExit() {
        SWTBotMenu fileMenu = bot.menu("Filejhsdfbjhsdbfdsjhbdfjhbfdjh");
        Assert.assertNotNull(fileMenu);
    }
Re: SWTBot and E4 RCP Applications - Status? [message #1784872 is a reply to message #1784852] Thu, 05 April 2018 03:30 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

All I can say is that the tests work for me. Does it help to use a fresh workspace?
Re: SWTBot and E4 RCP Applications - Status? [message #1784891 is a reply to message #1784872] Thu, 05 April 2018 09:08 Go to previous messageGo to next message
Robert Hilbrich is currently offline Robert HilbrichFriend
Messages: 24
Registered: April 2018
Location: Berlin
Junior Member

I works now - thank you! I think my launcher was not properly configured. I restarted the test without a launcher - "Run As" --> "SWTBot Test" and now it works.

Thanks a lot for your help!

Robert
Re: SWTBot and E4 RCP Applications - Status? [message #1784901 is a reply to message #1784891] Thu, 05 April 2018 12:54 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

Huh, I was using your JUnit Plugin Test and it was fine. But that's good to hear.
Previous Topic:Automated test execution without showing display
Next Topic:SWTBot tests do not work with maven, but with Eclipse
Goto Forum:
  


Current Time: Sun Oct 17 14:04:23 GMT 2021

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

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

Back to the top