-
-
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
Detecting cycles in inner class hierarchies throws exceptions even for classes not marked as @Nested #2249
Comments
I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference. |
No. There is unfortunately no way to disable the cycle detection, but we'll look into fixing the issue. Thanks for bringing this to our attention! |
sbrannen
added a commit
that referenced
this issue
Apr 7, 2020
7 tasks
sbrannen
added a commit
that referenced
this issue
Apr 9, 2020
sbrannen
added a commit
that referenced
this issue
Apr 9, 2020
JUnit 5.6 introduced inner class cycle detection in ReflectionSupport.findNestedClasses() (see #2039). Unfortunately, the cycle detection introduced a regression for test classes that contain classes with inner class cycles when those inner classes do not match the predicate supplied to findNestedClasses() (e.g., "is annotated with @nested"). Consequently, an exception is thrown for any inner class cycled detected, even if the cycle would not adversely affect test discovery or execution. This commit fixes this regression by avoiding inner class cycle detection for candidate classes that do match the predicate. For example, within JUnit Jupiter inner class cycle detection is now only performed for inner classes annotated with @nested. Fixes #2249
sbrannen
added a commit
that referenced
this issue
Apr 9, 2020
JUnit 5.6 introduced inner class cycle detection in ReflectionSupport.findNestedClasses() (see #2039). Unfortunately, the cycle detection introduced a regression for test classes that contain classes with inner class cycles when those inner classes do not match the predicate supplied to findNestedClasses() (e.g., "is annotated with @nested"). Consequently, an exception is thrown for any inner class cycled detected, even if the cycle would not adversely affect test discovery or execution. This commit fixes this regression by avoiding inner class cycle detection for candidate classes that do match the predicate. For example, within JUnit Jupiter inner class cycle detection is now only performed for inner classes annotated with @nested. Fixes #2249
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Upgrading to JUnit 5.6 is breaking a unit test I have.
This class is defined in my test suite and the recursive check fails even though I have not marked any of these classes as
@Nested
.I think this is the suspect code:
/~https://github.com/junit-team/junit5/blob/master/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/predicates/IsTestClassWithTests.java#L46
/~https://github.com/junit-team/junit5/blob/master/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java#L1007-L1008
Notice that the code looks for all nested classes (and asserts on finding a cycle) before attempting to filter out using the predicate for
@Nested
. Therefore any class that has this inner inheritance (in my case GroovyClosure
andWriteableClosure
) is causing an error even if they are not marked as@Nested
.For reference, here is the closure code and its inner class:
/~https://github.com/groovy/groovy-core/blob/master/src/main/groovy/lang/Closure.java#L847
Is there a way for me to disable this recursion check?
The text was updated successfully, but these errors were encountered: