Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Does anyone test e(fx)clipse applications?(Not enough information about testing)
Does anyone test e(fx)clipse applications? [message #1763909] Mon, 22 May 2017 19:19 Go to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
Hi community,

I am wondering if anyone has run unit, functional and integration tests on e(fx)clipse applications and can comment on what the best approach is.

After some research in the Internet, I found that many people recommend writing test code using fragments for each plugin in e4 applications. Is this the recommended way for e(fx)clipse too? According to what I read, this approach is limited to JUnit 3.X tests or JUnit 4.x if one creates and maintains the test suites (I want to believe there is something better).

Also, what is the best way to launch and shutdown the whole application to perform functional and integration tests from the test class?

Since testing is a must in my case, I am giving a shot to the gradle Goomph plugin to try to run Tom's maven example using gradle. That would be the dream scenario for me because of how easily all kind of tests can run under gradle.

I requested some help from one of Goomph's programmers (Ned Twigg) and I would happily post here a working example if I ever get that far. If anyone is interested, the question thread is here: https://github.com/diffplug/goomph/issues/31

Thanks!
Re: Does anyone test e(fx)clipse applications? [message #1763939 is a reply to message #1763909] Tue, 23 May 2017 08:46 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well in our commerical application we:
* use MVVM and test those parts with simple JUnit-Tests because
* use TextFX for simple JUnit-Testing parts of the UI (if you follow our adviced component-structure each component can be started without OSGi and the e4 framework)
* use TestFX for integration tests (unfortunately publishing TextFX support at Eclipse.org is not going to happen because of license problems)
Re: Does anyone test e(fx)clipse applications? [message #1763941 is a reply to message #1763939] Tue, 23 May 2017 08:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I'm not sure goomph will be of much help for you, point 1 & 2 should get you quite far already by leveraging standard testing infrastructure. To make 3 working with TestFX you need to make JUnit launch the OSGi-Application for you. I hope we can allocate some time in the 4.0 timeframe to streamline support to ease JUnit-Testing.
Re: Does anyone test e(fx)clipse applications? [message #1763978 is a reply to message #1763941] Tue, 23 May 2017 14:33 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
Thanks for your answer Tom. You were right regarding Goomph. So far I could not find a way to lauch e(fx)clispe with it.

I still have a few doubts:

How do you organize your tests in those commercial applications? Do you put the unit tests in the same plugin or you use fragments for them? What about the integration tests? Do you have a separate plugin or fragment for them? Is there something considered a best practice that make testing e(fx)clispe applications easier?

Lastly, how do you make JUnit launch the OSGi-Application for testing?

Thanks!
Re: Does anyone test e(fx)clipse applications? [message #1769023 is a reply to message #1763939] Tue, 25 July 2017 19:03 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
Could anyone please post pom.xml files that illustrate the configuration of test fragments both for simple JUnit tests and TestFX tests?
I managed to run simple JUnit tests using a test fragement but it does not work under maven... I would like to see examples of those files to find out what I am doing wrong...
Thanks!
Re: Does anyone test e(fx)clipse applications? [message #1769047 is a reply to message #1769023] Wed, 26 July 2017 05:29 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
I wrote an article about OSGi testing a while ago [1]

It is about plain OSGi component testing, but maybe related. It could be that your transitive dependencies are not started up correctly, e.g. DS and EventAdmin.

My example [2] is based on pom-less Tycho and Neon as base platform, so there is no special configuration necessary for this anymore. But of course I don't know anything about your setup and if that helps.

[1] http://blog.vogella.com/2016/07/04/osgi-component-testing/
[2] https://github.com/fipro78/osgi-ds-getting-started-pde
Re: Does anyone test e(fx)clipse applications? [message #1769132 is a reply to message #1769047] Wed, 26 July 2017 22:55 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
@Dirk

Sorry for the late reply. I was aware of your tutorials and I was able to rest a project when JavaFX is not involved.

My current setup is extremely simple, since I want to figure out how to actually make test work. Starting with the template for creating a new e4 e(fx)clipse project, I added a plugin project with a simple class:

class Actor {	
	private StringProperty nameProperty = new SimpleStringProperty("Actor!");	
	String getName() {
		return nameProperty.get();
	}
}


and a fragment project for tests with the following class:

public class ActorTest {
	@Test
	public void testGetName() {
		Actor actor = new Actor();
		assertNotNull(actor.getName());
	}
}


both projects have a pom.xml pointing to the app.releng project.

If instead of using the SimpleStringProperty I use a hard-coded string, everything works. When using a JavaFX 8 class, then the test fails with:

java.lang.NoClassDefFoundError: javafx/beans/property/StringProperty


My expectation is that a e(fx)clispe project created with a template should provide all the configuration for testing JavaFX classes.

The launch file has
-Dorg.osgi.framework.bundle.parent=ext
as a VM argument. So I don't know what I'm missing.

I noticed the template created a pom.xml for the releng project with the following content under pluginManagement->Plugins->Tycho

...
<extraClasspathElements>
	<extraClasspathElement>
		<groupId>javafx</groupId>
		<artifactId>javafx.mvn</artifactId>
		<version>2.2.0-SNAPSHOT</version>
	</extraClasspathElement>
</extraClasspathElements>
...


Could that version (2.2.0-SNAPSHOT) be the problem?

Thanks

Re: Does anyone test e(fx)clipse applications? [message #1769146 is a reply to message #1769132] Thu, 27 July 2017 05:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Not sure if launch files are actually used by Tycho. Don't you need to provide VM parameters via Maven properties somehow?
Re: Does anyone test e(fx)clipse applications? [message #1769224 is a reply to message #1769146] Fri, 28 July 2017 04:01 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
@Dirk
Thanks for your answer. Could you please elaborate? Which parameter should I add? How and where can I do that?
Re: Does anyone test e(fx)clipse applications? [message #1769227 is a reply to message #1769224] Fri, 28 July 2017 05:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
You talked about the -Dorg.osgi.framework.bundle.parent=ext VM parameter in your launch file. And I would try to set it in the surefire configuration like shown here: http://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html

But to be honest, I never tried it before with e(fx)clipse
Re: Does anyone test e(fx)clipse applications? [message #1769234 is a reply to message #1769227] Fri, 28 July 2017 06:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
the following needs to go in your pom.xml

<build>
		<resources>
			<resource>
				<directory>.</directory>
				<includes>
					<include>META-INF/</include>
				</includes>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-surefire-plugin</artifactId>
				<version>${tycho-version}</version>
				<configuration>
					<argLine>-Dorg.osgi.framework.bundle.parent=ext</argLine>
				</configuration>
			</plugin>
		</plugins>
	</build>
Re: Does anyone test e(fx)clipse applications? [message #1769286 is a reply to message #1769234] Fri, 28 July 2017 15:35 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
@Dirk

Thanks for the information. I have seen a video (I can't remember which one right now) that recommended using tycho surefire only for UI tests and use maven surefire for the rest. They were claiming performance reasons in a CI environment. I have no idea if that suggestion is relevant for e(fx)clipse projects. I might give it a try after I get a basic project properly setup. Now I need to dig into TestFX and how to configure the project to be tested with it... fun times ahead...

Thanks for taking the time to answer me. I really appreciate it.


@Tom

Thanks for your post. I tried adding that to the test fragment's pom.xml and it works with maven now.

Is there a chance you could blog about the different test setups (for Unit, TestFX for parts of the UI and integration tests using TestFX) until we have a reference project?

There are tons of useful information there and I think this topic will be a nice one to add to your collection. On top of that, if anyone trying to learn this topics try to find the information by its own, s/he will have a hard time and might be discouraged to use e(fx)clipse to develop anything meaningful.

You mentioned you use Model-View-ViewModel to setup your projects. Have you also tried PresentationModel-View-Controller? This last pattern is the one I used when working on a Griffon application and made testing easier. Griffon also provides the magic that synchronizes the presentation model and the view using the right threads, so users never have to worry about threading problems with the UI. It's quite cool.

Anyway, thanks again for your help. I have been struggling with this for quite some time now. I am kind of surprised that nobody seems to be testing e(fx)clipse applications...

Re: Does anyone test e(fx)clipse applications? [message #1769303 is a reply to message #1769286] Fri, 28 July 2017 21:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I created a small sample project (note this is not the bigger tutorial sample i work on) at https://github.com/BestSolution-at/efxclipse-sample-mvvm it shows:
* useage of MVVM in e(fx)clipse
* useage TestFX to run UI test
Re: Does anyone test e(fx)clipse applications? [message #1769381 is a reply to message #1769303] Mon, 31 July 2017 08:14 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Unfortunately the tests for OSGi-Applications interfere often with those simple standard tests :-( It looks like tests are run before the first ones are finished! I'm not sure who is to blame but I guess because of all the licensing shit around TestFX and Eclipse.org projects we need to roll our own test framework.
Re: Does anyone test e(fx)clipse applications? [message #1769467 is a reply to message #1769381] Mon, 31 July 2017 19:49 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
Thanks for your help Tom. I will take a look at that project right now.
I hope they get the licensing thing resolved and that you don't have to create your own testing framework...
Re: Does anyone test e(fx)clipse applications? [message #1770071 is a reply to message #1769467] Tue, 08 August 2017 06:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
No the licensing problem CAN NOT be resolved and there are other problems with TestFX so I took some time off at the weekend and started implementing my own test-framework. See https://github.com/BestSolution-at/FX-Test it's not yet complete and many things you can do with TestFX are not implemented but it is a good starting point.
Re: Does anyone test e(fx)clipse applications? [message #1770517 is a reply to message #1770071] Sun, 13 August 2017 18:48 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
@Tom
Could you please tell me how to add FX-Test to my project?
I copied and pasted the pom.xml you show in the github repository in my test project (updating my project name).
I then tried to create the test extending
E4JunitTestCase
but Eclipse cannot resolve it.
Is there a P2 repository for the snapshot version of FX-Test that I need to use?
Thanks!
Re: Does anyone test e(fx)clipse applications? [message #1770520 is a reply to message #1770517] Sun, 13 August 2017 21:02 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
http://downloads.foss.bestsolution.at/fx-test/snapshots/repository/
Re: Does anyone test e(fx)clipse applications? [message #1770522 is a reply to message #1770520] Sun, 13 August 2017 22:14 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
@Tom
Thank you for your answer. Would you mind telling me where to use that repository?
I tried under Help->Install New Software->Add and copied the link you provided, but eclipse can't find anything there...
I added it to my repositories section in my releng's pom.xml, but still nothing...
Could you please tell me what I'm doing wrong?
Thanks!
Re: Does anyone test e(fx)clipse applications? [message #1770530 is a reply to message #1770522] Mon, 14 August 2017 06:18 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
a) In Eclipse it has to be part of your target-platform
b) For tycho it has to be in your releng-pom like it is in the sample - https://github.com/BestSolution-at/FX-Test/blob/master/e4-test/sample.osgi.app.app.releng/pom.xml
Re: Does anyone test e(fx)clipse applications? [message #1770585 is a reply to message #1770530] Mon, 14 August 2017 16:18 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
Thanks for the answer Tom!
Re: Does anyone test e(fx)clipse applications? [message #1770609 is a reply to message #1770585] Tue, 15 August 2017 02:11 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
@Tom

I am trying Fx-Test. I know this is a work in progress. Are you open to suggestions/ideas/discussions? If so, where would be the best place?

Also, I am having trouble with Mockito. I added version 1.9.5 to the target definition, and also objenesis, but I does not work at all: it is unable to mock the class complaining it can only mock visible and non final classes (which is the case in my project). Mockito can't even mock a public non-final class with a public default constructor residing in the very same package of the test fragment...

The whole thing with Eclipse, adding dependencies to the target definition from P2 repositories and adding them also to pom.xml seems a nightmare to me... I can't wait to drop maven and P2 altogether and start building e(fx)clipse projects with gradle. :(

In the meantime, I would like to be able to use Mockito. Could you share how you setup Mockito in eclipse for your projects? I am not concern about the pom.xml dependency...

Thanks again!

[Updated on: Tue, 15 August 2017 04:57]

Report message to a moderator

Re: Does anyone test e(fx)clipse applications? [message #1770631 is a reply to message #1770609] Tue, 15 August 2017 09:59 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
- On FX-Test please file issues at github
- On mockito - i'm not using it because if you the service and di approach there should never be a reason to mock something
Re: Does anyone test e(fx)clipse applications? [message #1770662 is a reply to message #1770631] Tue, 15 August 2017 20:19 Go to previous messageGo to next message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
@Tom

As always, thanks again for your answer!

I'm kind of puzzled by your second statement: "I'm not using [Mockito] because if you use the service and di approach there should never be a reason to mock something".

I am using the service and dependency injection approach. To unit test whatever I am programing I was used to mock the service, set in the tested class, and verify interactions.

For example, lets assume I have a controller that requires a service that is injected by Eclipse's DI framework. The interaction in the controller happen when the different "onSomething" methods are called. My approach was to test the controller without the UI, mock the service and set it into the controller via a simple setter, and call the "onSomething" methods when I run the tests, verifying the controller calls the expected methods in the expected order on the mocked server. In this way I test only code in the controller. Isn't this a valid reason to use mocks? If not, could you tell me how you test this scenario?

Thanks again!
Re: Does anyone test e(fx)clipse applications? [message #1771094 is a reply to message #1770662] Mon, 21 August 2017 21:14 Go to previous message
Marcelo Ruiz is currently offline Marcelo RuizFriend
Messages: 80
Registered: April 2017
Member
Just in case someone is interested in using Mockito, the latest version (2.8.47 with updated dependencies) work with no problem.
Previous Topic:How can I add maven libraries to an e(fx)clipse project?
Next Topic:jetty upgrade problem
Goto Forum:
  


Current Time: Sat Nov 09 02:38:07 GMT 2024

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

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

Back to the top