-
-
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
DisplayNameGenerator
cannot access runtime enclosing type for @Nested
test class
#4130
Closed
1 task
Comments
sbrannen
changed the title
Nov 15, 2024
DisplayNameGenerator
cannot access type of enclosing instance for @Nested
test classDisplayNameGenerator
cannot access runtime enclosing type for @Nested
test class
Open
2 tasks
Team decision: Change @Deprecated
default String generateDisplayNameForNestedClass(Class<?> nestedClass) {
throw new UnsupportedOperationException("Implement generateDisplayNameForNestedClass(List<Class<?>>, Class<?>) instead")
}
default String generateDisplayNameForNestedClass(List<Class<?>> enclosingInstanceTypes, Class<?> nestedClass) {
return generateDisplayNameForNestedClass(nestedClass);
}
@Deprecated
default String generateDisplayNameForMethod(Class<?> testClass, Method testMethod) {
throw new UnsupportedOperationException("Implement generateDisplayNameForMethod(List<Class<?>>, Class<?>, Method) instead");
}
default String generateDisplayNameForMethod(List<Class<?>> enclosingInstanceTypes, Class<?> testClass,
Method testMethod) {
return generateDisplayNameForMethod(testClass, testMethod);
} In addition, the actual instance types need to be collected via the parent |
Hi, can I work on this issue? :) |
@neronsoda Yes, please go ahead! 👍 |
neronsoda
added a commit
to neronsoda/junit5
that referenced
this issue
Nov 27, 2024
6 tasks
1 task
6 tasks
marcphilipp
added a commit
that referenced
this issue
Jan 25, 2025
marcphilipp
added a commit
that referenced
this issue
Jan 25, 2025
6 tasks
6 tasks
marcphilipp
added a commit
that referenced
this issue
Jan 25, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
A
DisplayNameGenerator
can access the type of a@Nested
test class as well as the enclosing class in which a@Nested
test class is declared, but it cannot access the concrete runtime type of the enclosing instance for a@Nested
test class.When a
DisplayNameGenerator
is used to build hierarchical display names, this can lead to confusing results or even conflicting results depending on the structure of the test classes used, "conflicting" in the sense that two nested test classes may have identical display names that do not represent the runtime structure of the test classes.Example
Actual Behavior
When running
ScenarioOneTests
andScenarioTwoTests
, we currently see the following display names.ScenarioOneTests
AbstractBaseTests, NestedTests
AbstractBaseTests, NestedTests, test()
ScenarioTwoTests
AbstractBaseTests, NestedTests
AbstractBaseTests, NestedTests, test()
Expected Behavior
When running
ScenarioOneTests
andScenarioTwoTests
, we would expect the following display names.ScenarioOneTests
ScenarioOneTests, NestedTests
ScenarioOneTests, NestedTests, test()
ScenarioTwoTests
ScenarioTwoTests, NestedTests
ScenarioTwoTests, NestedTests, test()
Related Issues
@DisplayNameGeneration
is not discovered on runtime enclosing type for@Nested
test class #4131Deliverables
DisplayNameGenerator
can access the concrete runtime type of the enclosing instance for a@Nested
test class.The text was updated successfully, but these errors were encountered: