Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » PowerMock tests not working from tycho(PowerMock tests that work from eclipse, don't work from tycho)
PowerMock tests not working from tycho [message #1754114] Tue, 14 February 2017 15:16 Go to next message
Erik Vande Velde is currently offline Erik Vande VeldeFriend
Messages: 82
Registered: September 2012
Member
We are currently using a dedicated 3rd party library bundle in our product to make libraries like mockito, guava, etc ... available to other bundles. There we put all libraries in a 'lib' sub-directory, include them in the Bundle-ClassPath of the manifest, and export all their packages from the same manifest. This always worked correctly, but now we are having trouble with powermock. If we include that in the 3rd party bundle, and we don't add junit there, the tests using powermock show an 'initializationError: Type [unknown] not present'. If we add powermock AND junit in the library bundle, we see 'initializationError: PowerMockExampleTest cannot be found by thirdparty.libsbundle_with_junit'.
If we just include the 3rd party libraries in the test bundle itself, in a lib sub-directory, everything works like a charm, but that would mean we have to add these libraries to every bundle that wants to use them.
My questions:
(1) Why would the 3rd party bundle need the test class PowerMockExampleTest , instead of the other way around, and how can we provide it ??
(2) What is the current preferred way to add 3rd party libraries to an e4 project (many people say 'use orbit', but they don't always have the wanted version of a library, if it exists at all).
I've just uploaded a sample project to github if someone would like to reproduce the problems I'm talking about here: see https://github.com/erikatfugro/e4-3rd-party-libs
Re: PowerMock tests not working from tycho [message #1754118 is a reply to message #1754114] Tue, 14 February 2017 15:32 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
It is an OSGi problem that the library in charge is not designed to work well in an OSGi context. Typically because it uses some ClassLoader APIs or rely on the fact that everything is in the same classloader.

I typically search for an OSGi version somewhere in the wild, like e.g. in Orbit. For Powermock I found this one: https://github.com/powermock/powermock/wiki/osgi

Otherwise make the library an OSGi bundle yourself, which is what you are trying to do with the monster bundle that contains all libraries. Typically a bad practice, but well it could work. But as Powermock seems to rely on some JUnit classes on the same classpath, it fails. Hard to say why. There are some tickets around if you use a search engine of your choice. Wink
Re: PowerMock tests not working from tycho [message #1754220 is a reply to message #1754118] Wed, 15 February 2017 13:52 Go to previous message
Erik Vande Velde is currently offline Erik Vande VeldeFriend
Messages: 82
Registered: September 2012
Member
If I try to add the update site http://powermock-osgi.googlecode.com/svn/updateSite/1.5.6.0 to my target platform it just cannot find it. So I guess our only practical option is to add the libs in every bundle where we need powermock ...
Previous Topic:Best practice from making programmatic changes to part from handler?
Next Topic:Fragments not visible after Product Export
Goto Forum:
  


Current Time: Thu Apr 25 09:44:26 GMT 2024

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

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

Back to the top