Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] Is there a way to have src/ and test/ in the same eclipse plug-in?

Well you can compile the test folder separately.

 

source.. = src/

source.tests.jar = test/

bin.excludes = tests.jar

jars.compile.order = .,\

                                          tests.jar

 

We were doing something like this before with PDE and I can tell you it sucked and I was glad to be rid of it when we switched to Maven/Tycho.

 

The main complications are dependency management and running unit tests in an OSGi environment. You don’t want your main bundle to depend on things like junit or mockito or things like that, you want those in the manfiest of your test plugin. And Tycho-surefire doesn’t do anything for a project with eclipse-plugin packaging. So you’d be losing out on the integration of running your unit tests in an OSGi environment as part of the maven lifecycle. The perceived advantage of having fewer Eclipse projects is actually a disadvantage. Each jar file is compiled independently of the other on the command-line, but a single Eclipse workspace compiles both code trees together. We would occasionally see people commit code that compiled in the IDE but not from the command-line because of this.

 

Totally not worth the hassle. Having the unit tests as a fragment bundle with their own dependencies is much easier to deal with.

 

From: tycho-user-bounces@xxxxxxxxxxx [mailto:tycho-user-bounces@xxxxxxxxxxx] On Behalf Of Jeff MAURY
Sent: Friday, January 17, 2014 9:46 AM
To: Tycho user list
Subject: Re: [tycho-user] Is there a way to have src/ and test/ in the same eclipse plug-in?

 

Tycho being based on the PDE info to build the bundle, it is impossible if you've got a single bundle to generate the JAR without the test classes !!!!

 

Jeff

 

On Fri, Jan 17, 2014 at 4:39 PM, Jeremie Bresson <Jeremie.Bresson@xxxxxxxxx> wrote:

Hi,

 

When it comes to the location of unit tests, there are different possibilities (this stack overflow question [1] provides a good overview).

 

Until now I have always seen unit test code in separated fragment (the “eclipse way”).

To use this approach the pom.xml of the fragment contains <packaging>eclipse-test-plugin</packaging> and everything works fine with tycho.

 

I was challenged to know if it would be possible to have the tests in the same plug-in:

myplugin

--- src

------ myplugin.package1

--------- ...java

--- test

------ myplugin.package1.test

--------- ...Test.java

--- META-INF

------ MANIFEST.MF

...

 

The advantages mentioned with this approach are:

* keeping the overview by having the source and the test code near.

* having only one maven module instead of two.

* reducing the amount of eclipse projects in the workspace.

 

 

I am well aware that this is not a standard eclipse approach.

 

Something I do not know is:

=> What would be the approach to build the plugin and run the tests in such a case?

=> Do you have some pointers of developers who experiment this approach?

 

My goal is not to end up by doing a pom-first approach, but to understand what is currently missing (tycho, eclipse…) in order to have the test folder in the same plug-in.

 

Thanks in advance,

 

Jérémie

 

[1] http://stackoverflow.com/questions/12372730/osgi-unit-testing-and-bundle-exports

 

 


_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/tycho-user



 

--
Jeff MAURY


"Legacy code" often differs from its suggested alternative by actually working and scaling.
 - Bjarne Stroustrup

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury


This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

Back to the top