Skip to main content



      Home
Home » Archived » Tycho » IllegalAccessErrors Running JUnit Tests During Build(Tests pass using JUnit Runner but fail when doing maven/tycho/surefire build.)
IllegalAccessErrors Running JUnit Tests During Build [message #634067] Wed, 20 October 2010 08:54 Go to next message
Eclipse UserFriend
I have a plugin (org.a.test) that is used to test another plugin (org.a). Both plugins have the same Java packages defined. The classes being tested in org.a have "protected" and package private methods. When I do a build using Tycho both jars (org.a, org.a.test) build fine.

However, during the build when the JUnit tests are run I get a runtime java.lang.IllegalAccessError whenever a test plugin class calls one of these protected methods. All the tests run successfully within Eclipse using the JUnit runner. I have Eclipse's compiler setting for "forbidden reference access rules" set to be an error.

Any ideas?

Thanks!
Re: IllegalAccessErrors Running JUnit Tests During Build [message #634156 is a reply to message #634067] Wed, 20 October 2010 11:52 Go to previous messageGo to next message
Eclipse UserFriend
you need to use a test fragment instead of a test plugin in order to access
package-private members
This is not a tycho issue but rather how OSGi behaves at runtime

Regards
Jan

"elvisisking" <dflorian@redhat.com> wrote in message
news:i9mojo$m85$1@news.eclipse.org...
>I have a plugin (org.a.test) that is used to test another plugin (org.a).
>Both plugins have the same Java packages defined. The classes being tested
>in org.a have "protected" and package private methods. When I do a build
>using Tycho both jars (org.a, org.a.test) build fine.
> However, during the build when the JUnit tests are run I get a runtime
> java.lang.IllegalAccessError whenever a test plugin class calls one of
> these protected methods. All the tests run successfully within Eclipse
> using the JUnit runner. I have Eclipse's compiler setting for "forbidden
> reference access rules" set to be an error.
>
> Any ideas?
>
> Thanks!
Re: IllegalAccessErrors Running JUnit Tests During Build [message #634453 is a reply to message #634156] Thu, 21 October 2010 14:39 Go to previous messageGo to next message
Eclipse UserFriend
So by your response you're saying when I use the JUnit runner within Eclipse to run the tests (which all pass), that OSGi is not being used then. I thought Eclipse used the OSGi framework. Is that not the case?

Does anyone know the steps to convert a plugin to a fragment?

Thanks!
Re: IllegalAccessErrors Running JUnit Tests During Build [message #634630 is a reply to message #634453] Fri, 22 October 2010 09:25 Go to previous message
Eclipse UserFriend
Run As > Junit test runs plain Junit tests, Run As > Junit plugin tests runs Junit inside OSGI (which is what tycho also does)
Previous Topic:Downloading Tycho / Maven
Next Topic:Has anyone successfully built a RAP app using Maven Tycho?
Goto Forum:
  


Current Time: Thu Jul 24 14:23:08 EDT 2025

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

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

Back to the top