-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AbstractRuleExtension can't load rule classes in OSGi runtime #1852
Labels
Comments
I could open a PR with my thought from the Additional Context that idea makes sense. |
@mpiggott adding an optional reference class for the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
AbstractRuleExtension
usesReflectionUtil.loadClassIfAvailable()
to attempt to load JUnit 4 rule classes.ReflectionUtil
attempts to load the classes in the context ofspock-core
which does not import junit4 packages. In an OSGi environment the rules classes are not on the classpath of thespock-core
bundle .To Reproduce
@Rule
or other JUnit 4 rulesExpected behavior
JUnit 4 rules work in OSGi
Actual behavior
JUnit4 extensions for rules do not function
Java version
Eclipse Adoptium 8.0.382.5
Buildtool version
Not applicable
What operating system are you using
Windows
Dependencies
Additional context
It may make sense to have add a method to
ReflectionUtil
which a caller could provide aClass
to use for loading, e.g.ReflectionUtil.loadClassIfAvailable(Class<?> cp, String className)
which would usecp.getClassLoader()
as opposed toReflectionUtil.class.getClassLoader()
.Callers outside of
spock-core
(e.g.spock-junit4
) would provide their own context e.g.ReflectionUtil.loadClassIfAvailable(AbstractRuleExtension.class, "org.junit.Rule")
The text was updated successfully, but these errors were encountered: