Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » How to run unit tests in an e4 + e(fx)clipse project?
How to run unit tests in an e4 + e(fx)clipse project? [message #1412416] Tue, 26 August 2014 05:26 Go to next message
Fernando Paz is currently offline Fernando PazFriend
Messages: 22
Registered: May 2014
Junior Member
I want to run some JUnit tests in my e4 + e(fx)clipse application, but I'm struggling with Maven at this point.

I've read that the recommended approach[1] is to create an Eclipse fragment and write some tests on it. Accordingly to Tycho wiki[2], I would need to declare a dependency to the feature (because my tests require some plugins provided by e(fx)clipse), so I came up with the following pom for the test fragment:

<?xml version="1.0" encoding="UTF-8"?>
<project
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<artifactId>lab.poc.unittests.app.tests</artifactId>
	<packaging>eclipse-test-plugin</packaging>

	<name>Unit Tests POC</name>
	<description>Unit Tests POC</description>

	
	<parent>
		<groupId>lab.poc.unittests</groupId>
		<artifactId>lab.poc.unittests.app.releng</artifactId>
		<relativePath>../lab.poc.unittests.app.releng/pom.xml</relativePath>
		<version>1.0.0</version>
	</parent>

	<build>
		<sourceDirectory>src</sourceDirectory>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-surefire-plugin</artifactId>
				<version>${tycho-version}</version>
				<configuration>
					<useUIHarness>true</useUIHarness>
					<dependencies>
			            <dependency>
			                <type>eclipse-feature</type>
			                <artifactId>lab.poc.unittests.app.feature</artifactId>
			                <version>0.0.0</version>
			            </dependency>
			        </dependencies>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>


However, when I run mvn clean verify in my releng pom I get the following error:

[INFO] --- tycho-surefire-plugin:0.21.0:test (default-test) @ lab.poc.unittests.app.tests ---
[INFO] Cannot complete the request.  Generating details.
[INFO] Cannot complete the request.  Generating details.
[INFO] {osgi.os=noenv, osgi.ws=noenv, org.eclipse.update.install.features=true, osgi.arch=noenv}
[ERROR] Cannot resolve project dependencies:
[ERROR]   You requested to install 'lab.poc.unittests.app.feature.feature.group 0.0.0' but it could not be found
[ERROR]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Unit Tests POC - releng ........................... SUCCESS [  0.085 s]
[INFO] Unit Tests POC - application bundle ............... SUCCESS [  1.710 s]
[INFO] Unit Tests POC - application feature .............. SUCCESS [  0.292 s]
[INFO] Unit Tests POC - application product .............. SUCCESS [  5.269 s]
[INFO] Unit Tests POC .................................... FAILURE [  0.335 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.392 s
[INFO] Finished at: 2014-08-26T17:05:37+12:00
[INFO] Final Memory: 47M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test (default-test) on project lab.poc.unittests.app.tests: Execution default-test of goal org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test failed: No solution found because the problem is unsatisfiable.: [Unable to satisfy dependency from tycho-extra-1409029537154 0.0.0.1409029537154 to lab.poc.unittests.app.feature.feature.group 0.0.0.; Unable to satisfy dependency from tycho-1409029537177 0.0.0.1409029537177 to lab.poc.unittests.app.feature.feature.group 0.0.0.; No solution found because the problem is unsatisfiable.] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :lab.poc.unittests.app.tests


In the end, as the e(fx)clipse uses a different target platform, I'm not even sure if this is right approach to test an e4 + e(fx)clipse project. How are you guys doing this?


[1]: http://www.vogella.com/tutorials/Eclipse4Testing/article.html
[2]: https://wiki.eclipse.org/Tycho/Packaging_Types#eclipse-test-plugin
Re: How to run unit tests in an e4 + e(fx)clipse project? [message #1412441 is a reply to message #1412416] Tue, 26 August 2014 07:06 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

The first question is. Are you writing UI-Tests or NONE-UI-Tests?

Unfortunately the error message tycho provides is not very useful but it
looks like the feature is missing some dependency but I can't tell you
which ones are missing.

Are you able to run your JUnit-Tests inside the IDE?

Tom

On 26.08.14 07:26, Fernando Paz wrote:
> I want to run some JUnit tests in my e4 + e(fx)clipse application, but
> I'm struggling with Maven at this point.
>
> I've read that the recommended approach[1] is to create an Eclipse
> fragment and write some tests on it. Accordingly to Tycho wiki[2], I
> would need to declare a dependency to the feature (because my tests
> require some plugins provided by e(fx)clipse), so I came up with the
> following pom for the test fragment:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd"
> xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <modelVersion>4.0.0</modelVersion>
> <artifactId>lab.poc.unittests.app.tests</artifactId>
> <packaging>eclipse-test-plugin</packaging>
>
> <name>Unit Tests POC</name>
> <description>Unit Tests POC</description>
>
>
> <parent>
> <groupId>lab.poc.unittests</groupId>
> <artifactId>lab.poc.unittests.app.releng</artifactId>
>
> <relativePath>../lab.poc.unittests.app.releng/pom.xml</relativePath>
> <version>1.0.0</version>
> </parent>
>
> <build>
> <sourceDirectory>src</sourceDirectory>
> <plugins>
> <plugin>
> <groupId>org.eclipse.tycho</groupId>
> <artifactId>tycho-surefire-plugin</artifactId>
> <version>${tycho-version}</version>
> <configuration>
> <useUIHarness>true</useUIHarness>
> <dependencies>
> <dependency>
> <type>eclipse-feature</type>
>
> <artifactId>lab.poc.unittests.app.feature</artifactId>
> <version>0.0.0</version>
> </dependency>
> </dependencies>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> </project>
>
>
> However, when I run mvn clean verify in my releng pom I get the
> following error:
>
>
> [INFO] --- tycho-surefire-plugin:0.21.0:test (default-test) @
> lab.poc.unittests.app.tests ---
> [INFO] Cannot complete the request. Generating details.
> [INFO] Cannot complete the request. Generating details.
> [INFO] {osgi.os=noenv, osgi.ws=noenv,
> org.eclipse.update.install.features=true, osgi.arch=noenv}
> [ERROR] Cannot resolve project dependencies:
> [ERROR] You requested to install
> 'lab.poc.unittests.app.feature.feature.group 0.0.0' but it could not be
> found
> [ERROR]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Summary:
> [INFO]
> [INFO] Unit Tests POC - releng ........................... SUCCESS [
> 0.085 s]
> [INFO] Unit Tests POC - application bundle ............... SUCCESS [
> 1.710 s]
> [INFO] Unit Tests POC - application feature .............. SUCCESS [
> 0.292 s]
> [INFO] Unit Tests POC - application product .............. SUCCESS [
> 5.269 s]
> [INFO] Unit Tests POC .................................... FAILURE [
> 0.335 s]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 14.392 s
> [INFO] Finished at: 2014-08-26T17:05:37+12:00
> [INFO] Final Memory: 47M/114M
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test (default-test) on
> project lab.poc.unittests.app.tests: Execution default-test of goal
> org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test failed: No solution
> found because the problem is unsatisfiable.: [Unable to satisfy
> dependency from tycho-extra-1409029537154 0.0.0.1409029537154 to
> lab.poc.unittests.app.feature.feature.group 0.0.0.; Unable to satisfy
> dependency from tycho-1409029537177 0.0.0.1409029537177 to
> lab.poc.unittests.app.feature.feature.group 0.0.0.; No solution found
> because the problem is unsatisfiable.] -> [Help 1]
> [ERROR]
> [ERROR] To see the full stack trace of the errors, re-run Maven with the
> -e switch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR]
> [ERROR] For more information about the errors and possible solutions,
> please read the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
> [ERROR]
> [ERROR] After correcting the problems, you can resume the build with the
> command
> [ERROR] mvn <goals> -rf :lab.poc.unittests.app.tests
>
>
> In the end, as the e(fx)clipse uses a different target platform, I'm not
> even sure if this is right approach to test an e4 + e(fx)clipse project.
> How are you guys doing this?
>
>
> [1]: http://www.vogella.com/tutorials/Eclipse4Testing/article.html
> [2]: https://wiki.eclipse.org/Tycho/Packaging_Types#eclipse-test-plugin
Re: How to run unit tests in an e4 + e(fx)clipse project? [message #1412692 is a reply to message #1412441] Tue, 26 August 2014 21:00 Go to previous messageGo to next message
Fernando Paz is currently offline Fernando PazFriend
Messages: 22
Registered: May 2014
Junior Member
Hi Tom.

For this example I'm writing non-UI tests, but surely I will cover UI tests in the future.
And yes, I'm able to run the JUnit tests inside Eclipse.

Do you think this might be related to the target platform?
Re: How to run unit tests in an e4 + e(fx)clipse project? [message #1412698 is a reply to message #1412692] Tue, 26 August 2014 21:26 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
My guess is that you miss a bundle in your test feature. What you can
try is to make the tooling generated a Jemmy-Unit-Test for you. For that
to work you need to add
http://downloads.efxclipse.bestsolution.at/p2-repos/addons/nightly/site/
to your target so that you have the Jemmy stuff.

If you then bootstrap an e4 application it will give you the option to
also generate a Jemmy JUnit-Test. Unfortunately there's a bug in there's
a bug in the code (see "Using Jemmy for e4 javafx application") so the
JUnit-Test will not launch but it should provide you guidance on how to
bootstrap JUnit on maven-tycho.

Tom

On 26.08.14 23:00, Fernando Paz wrote:
> Hi Tom.
>
> For this example I'm writing non-UI tests, but surely I will cover UI
> tests in the future.
> And yes, I'm able to run the JUnit tests inside Eclipse.
>
> Do you think this might be related to the target platform?
Re: How to run unit tests in an e4 + e(fx)clipse project? [message #1423788 is a reply to message #1412698] Mon, 15 September 2014 02:17 Go to previous messageGo to next message
Fernando Paz is currently offline Fernando PazFriend
Messages: 22
Registered: May 2014
Junior Member
Hi Tom.

After some research, I found out that I had to use another Tycho plugin in my pom:
<build>
		<sourceDirectory>src</sourceDirectory>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>target-platform-configuration</artifactId>
				<configuration>
					<dependency-resolution>
						<extraRequirements>
							<requirement>
			                	<type>eclipse-feature</type>
								<id>lab.poc.unittests.app.feature</id>
								<versionRange>0.0.0</versionRange>
							</requirement>
						</extraRequirements>
					</dependency-resolution>
				</configuration>
			</plugin>
		</plugins>
	</build>


However, it still complains about missing JavaFX packages. I'm pretty sure that I got the right plugins are included in my feature, otherwise the application wouldn't run, right?
!STACK 0
java.lang.NoClassDefFoundError: javafx/stage/Stage
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
	at java.lang.Class.getDeclaredMethods(Class.java:1962)
	at org.eclipse.equinox.internal.ds.model.ServiceComponent.getMethod(ServiceComponent.java:126)
	at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:213)
	at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
	at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
	at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
	at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
	at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
	at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
	at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
	at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
	at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: javafx.stage.Stage cannot be found by lab.poc.unittests.app.mainview_1.0.0
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:423)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:336)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:328)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 15 more


Re: How to run unit tests in an e4 + e(fx)clipse project? [message #1423895 is a reply to message #1423788] Mon, 15 September 2014 06:21 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Not finding javafx classes means that the osgi-hooks are not loaded
appropriately. Did you look at what the tooling generates if you want to
run Jemmy-Tests?

Tom

On 15.09.14 04:17, Fernando Paz wrote:
> Hi Tom.
>
> After some research, I found out that I had to use another Tycho plugin
> in my pom:
>
> <build>
> <sourceDirectory>src</sourceDirectory>
> <plugins>
> <plugin>
> <groupId>org.eclipse.tycho</groupId>
> <artifactId>target-platform-configuration</artifactId>
> <configuration>
> <dependency-resolution>
> <extraRequirements>
> <requirement>
> <type>eclipse-feature</type>
> <id>lab.poc.unittests.app.feature</id>
> <versionRange>0.0.0</versionRange>
> </requirement>
> </extraRequirements>
> </dependency-resolution>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
>
> However, it still complains about missing JavaFX packages. I'm pretty
> sure that I got the right plugins are included in my feature, otherwise
> the application wouldn't run, right?
>
> !STACK 0
> java.lang.NoClassDefFoundError: javafx/stage/Stage
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
> at java.lang.Class.getDeclaredMethods(Class.java:1962)
> at
> org.eclipse.equinox.internal.ds.model.ServiceComponent.getMethod(ServiceComponent.java:126)
>
> at
> org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:213)
>
> at
> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
>
> at
> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
>
> at
> org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
>
> at
> org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
>
> at
> org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
>
> at
> org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
>
> at
> org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
> at
> org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
>
> at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.ClassNotFoundException: javafx.stage.Stage cannot
> be found by lab.poc.unittests.app.mainview_1.0.0
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:423)
>
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:336)
>
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:328)
>
> at
> org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> ... 15 more
>
>
>
Previous Topic:error in Create New FXML Document wizard ?
Next Topic:Problem loading FXML files
Goto Forum:
  


Current Time: Thu Mar 28 20:00:54 GMT 2024

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

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

Back to the top