-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Test discovery failing with NullPointerException when trying to find methods of a test class #4076
Milestone
Comments
@pshevche Thanks for reporting! I have a reproducer on Java 8 (probably related to JDK-8193889) when a class in the default package extends a class from a non-default package and both declare a package private method with the same signature. |
marcphilipp
added a commit
that referenced
this issue
Oct 17, 2024
6 tasks
6 tasks
marcphilipp
added a commit
that referenced
this issue
Oct 17, 2024
marcphilipp
added a commit
that referenced
this issue
Oct 17, 2024
`Class.getPackage()` returns `null` for the default package on Java 8. This is now handled by inspecting the fully qualified class name rather than throwing a `NullPointerException`. Fixes #4076.
@marcphilipp , aha, that's the bit I was missing: the parent class needs to be in a non-default package. Thank you for taking care of it so rapidly! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
We observe test discovery failing with a
NullPointerException
when trying to find test class methods (stacktrace is attached below). This seems to be a regression in 1.11.x version ofjunit-platform-commons
. Discovery succeeds when using 1.10.x versions. Apparently, the.getPackage()
in this method can yieldnull
:junit5/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java
Lines 1905 to 1907 in 0de9d10
According to the docs this can happen if the package object is not created by the classloader. I have not been able to create a standalone reproducer yet, but I'll keep trying :) So far, we've seen this happen only when running Spock 1.3 tests located in the root package.
Stacktrace
The text was updated successfully, but these errors were encountered: