How to test Eclipse (OSGi) Bundles ?

391 views
Skip to first unread message

Christian Schwarz

unread,
Jan 6, 2014, 9:14:06 AM1/6/14
to pitu...@googlegroups.com
I tried to test a simple eclipse project with pitest+piclipse. Unfortunatly pitest doesn't recognize the bundle dependencies when running a test, so i get numerous NoClassDefFoundError's. Did anybody know how to run pitest with eclipse bundles? Maybe it works with Maven-Tycho + Surefire?

henry

unread,
Jan 6, 2014, 3:33:40 PM1/6/14
to pitu...@googlegroups.com


On Monday, 6 January 2014 14:14:06 UTC, Christian Schwarz wrote:
I tried to test a simple eclipse project with pitest+piclipse. Unfortunatly pitest doesn't recognize the bundle dependencies when running a test, so i get numerous NoClassDefFoundError's. Did anybody know how to run pitest with eclipse bundles? Maybe it works with Maven-Tycho + Surefire?

Hi Christian,

I've never tried to mutate an eclipse plugin project, but things are generally more likely to work via the maven mojo than pitclipse, so that would be worth a try.

I'd be interested to hear how you get on.

Thanks

Henry

Christian Schwarz

unread,
Jan 7, 2014, 2:45:11 AM1/7/14
to pitu...@googlegroups.com
Just another question before i start trying to "pitest" a eclipse bundle. Does pitest support multiple classloader? If not i guess it doesn't work at all, since every bundle has ist own classloader.

henry

unread,
Jan 7, 2014, 3:30:05 PM1/7/14
to pitu...@googlegroups.com


On Tuesday, 7 January 2014 07:45:11 UTC, Christian Schwarz wrote:
Just another question before i start trying to "pitest" a eclipse bundle. Does pitest support multiple classloader? If not i guess it doesn't work at all, since every bundle has ist own classloader.

PIT has no general issue with classloaders - many mocking frameworks and libraries like RoboElectric create custom classloaders within tests. That is of course no guarantee that something won't trip things up with the eclipse bundle.

Christian Schwarz

unread,
Jan 8, 2014, 7:56:15 AM1/8/14
to pitu...@googlegroups.com
I managed to integrate pitest into our maven-tycho build system on jenkins/hudson. The pitest-coverage goal get started, but failed with the following error:

No test library found on classpath. PIT requires either JUnit 4 (but can run JUnit 3 tests) or TestNG

I must admit that i am a maven and tycho newbie. Why must the classpath specified isn't tycho-surefire aware of it? 
When i run the build job without the pitest-coverage goal everthing works fine and all tests are executed by tycho-surefire.

henry

unread,
Jan 8, 2014, 5:13:22 PM1/8/14
to pitu...@googlegroups.com

I'm also a tycho newbie. I've no idea what the issue is - if you can put together a minimum project that demonstrates the issue I can take a look and see if I can work out what it going on.

Thanks

Henry

Christian Schwarz

unread,
Jan 9, 2014, 3:52:02 AM1/9/14
to pitu...@googlegroups.com
Hi, i also asked this question at the tycho mailing list.

 by Jeff Maury:
I'm not an expert with PiTest but according to the web site, PiTest does have its own main class which is in contrast with OSGI as OSGI containers are also main entry points for the JVM.
Jacoco solved the issue by being a Java agent so its is compatible with any runner: Maven surefire, TYcho surefire, JVM,...

So it seems PiTest and OSGi won't work together out of the box. Maybe it is possible to write an agent that does the same as the main-method of pitest. As far as i understand pitest uses it own mechanics to find Unit-Tests to execute, while in an OSGi build enviroment tycho-surefire did the job. It is also used to launch the OSGi enviroment using a main-method, thus PiTest don't work. 
Here the things get complicated, is it even possible to run pitest as agent? Is it possible to do disable the tycho or pitest unit-test find mechanism to avoid conficts? 

Henry Coles

unread,
Jan 9, 2014, 5:50:52 AM1/9/14
to pitu...@googlegroups.com
At the moment I don't really understand what the problem is so it's too soon to start talking about how to solve it. There might be a trivial fix, or it might be unsolvable.

If you can put together a minimal project that demonstrates the issue I'll dig into it when I have chance.

Thanks

Henry

Christian Schwarz

unread,
Jan 10, 2014, 5:40:32 AM1/10/14
to pitu...@googlegroups.com, henry...@googlemail.com
If you can put together a minimal project that demonstrates the issue I'll dig into it when I have chance.

You can clone the tycho demo repository and try to build project "itp01"  -> git://git.eclipse.org/gitroot/tycho/org.eclipse.tycho-demo.git 
The Project contains a simple application bundle an a test bundle, you only have to add the pitest plugin to the master pom.
I was able to reproduce the problem with this configuration.

Kind Regards
Chris

henry

unread,
Jan 10, 2014, 7:21:51 AM1/10/14
to pitu...@googlegroups.com, henry...@googlemail.com


On Friday, 10 January 2014 10:40:32 UTC, Christian Schwarz wrote:

You can clone the tycho demo repository and try to build project "itp01"  -> git://git.eclipse.org/gitroot/tycho/org.eclipse.tycho-demo.git 
The Project contains a simple application bundle an a test bundle, you only have to add the pitest plugin to the master pom.
I was able to reproduce the problem with this configuration.


Ok I'll take a look as soon as I get chance.

Thanks

Henry

Christian Schwarz

unread,
Jan 30, 2014, 3:32:32 AM1/30/14
to pitu...@googlegroups.com, henry...@googlemail.com
Am Freitag, 10. Januar 2014 13:21:51 UTC+1 schrieb henry:
Ok I'll take a look as soon as I get chance.

Sounds good, let me know if you need some support or more informations!

Cheers
Chris 

Perham X

unread,
Jul 22, 2014, 8:32:39 AM7/22/14
to pitu...@googlegroups.com, henry...@googlemail.com
Hi, I'm having the same problem with OSGI and Tycho. is there any news on this topic? I'm using PIT for my masters thesis and making this work would be a huge help for me. if I can help in any way please let me know.

henry

unread,
Jul 23, 2014, 10:12:53 AM7/23/14
to pitu...@googlegroups.com, henry...@googlemail.com

On Tuesday, 22 July 2014 13:32:39 UTC+1, Perham X wrote:
Hi, I'm having the same problem with OSGI and Tycho. is there any news on this topic? I'm using PIT for my masters thesis and making this work would be a huge help for me. if I can help in any way please let me know.


Afraid I'm time poor at the moment and haven't had chance to take a look.

Henry

Perham X

unread,
Jul 31, 2014, 10:35:30 AM7/31/14
to pitu...@googlegroups.com, henry...@googlemail.com
do you think it's possible to write an agent to do the job pit currently does on its own? I mean, what I need is that tycho-surefire-plugin gathers the tests and pit run those tests on the target mutated code. if this is possible, could you give me some pointers where to start? I have one month to figure this problem out, and I'd rather implement this feature in pitest rather than making another tool from scratch.

henry

unread,
Jul 31, 2014, 3:21:30 PM7/31/14
to pitu...@googlegroups.com, henry...@googlemail.com


On Thursday, 31 July 2014 15:35:30 UTC+1, Perham X wrote:
do you think it's possible to write an agent to do the job pit currently does on its own? I mean, what I need is that tycho-surefire-plugin gathers the tests and pit run those tests on the target mutated code. if this is possible, could you give me some pointers where to start? I have one month to figure this problem out, and I'd rather implement this feature in pitest rather than making another tool from scratch.


I've not been able to do enough investigation to determine if this is necessary - the problem might actually be very simple. Looking back over this thread I see christian got things going as far as this message


No test library found on classpath. PIT requires either JUnit 4 (but can run JUnit 3 tests) or TestNG

I gather the tycho convention is to put the tests in a separate project - if that is correct that would explain the issue. Pitest assumes the unit tests for some code live with that code. Quite how you would work round that isn't instantly clear, but shouldn't require writing an agent.

Henry

kpr

unread,
Nov 3, 2015, 3:14:15 AM11/3/15
to PIT Users, henry...@googlemail.com
Are there any updates on this issue? I tried running PIT against the tycho ipt01 example today but still ran into the same error message.

About the tycho convention: You can come across both test layouts simultaneously. Tests located in the same project/OSGi-Bundle or in a related fragment usually target the bundle alone (and often can be run as "normal" JUnit-Test). Tests in a separate project usually target more than one bundle at once (e.g. integration tests) and have to be run in an OSGi context in order to be able to resolve their dependencies.

henry

unread,
Nov 5, 2015, 4:28:17 PM11/5/15
to PIT Users, henry...@googlemail.com


On Tuesday, 3 November 2015 08:14:15 UTC, kpr wrote:
Are there any updates on this issue? I tried running PIT against the tycho ipt01 example today but still ran into the same error message.

About the tycho convention: You can come across both test layouts simultaneously. Tests located in the same project/OSGi-Bundle or in a related fragment usually target the bundle alone (and often can be run as "normal" JUnit-Test). Tests in a separate project usually target more than one bundle at once (e.g. integration tests) and have to be run in an OSGi context in order to be able to resolve their dependencies.



No update I'm afraid - I'd need to be able to find a big block of time to look at it and time is in short supply.

Henry

Perham

unread,
Nov 5, 2015, 6:04:30 PM11/5/15
to pitu...@googlegroups.com
Hi,

I wrote a mutation testing tool to overcome this issue. It is much slower than PIT because it mutates the source code, but it works. You can find it here: http://littledarwin.parsai.net

Regards,
Ali
--
You received this message because you are subscribed to a topic in the Google Groups "PIT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pitusers/IH21Q4jJaco/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pitusers+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages