Skip to content

Commit 31128d6

Browse files
committed
Ignore declaring class when equal to class name
1 parent aa4a84a commit 31128d6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

junit-platform-engine/src/main/java/org/junit/platform/engine/discovery/MethodSelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private MethodSelector(@Nullable ClassLoader classLoader, String className, Stri
120120
this.className = className;
121121
this.methodName = methodName;
122122
this.parameterTypeNames = parameterTypeNames;
123-
this.declaringClassName = declaringClassName;
123+
this.declaringClassName = className.equals(declaringClassName) ? null : declaringClassName;
124124
}
125125

126126
/**

platform-tests/src/test/java/org/junit/platform/engine/discovery/MethodSelectorTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ void distinguishesDeclaringClass() throws Exception {
9393
assertThat(childMethodSelector).isNotEqualTo(parentMethodSelector);
9494
}
9595

96+
@Test
97+
void ignoresDeclaringClassWhenEqualToClassname() throws Exception {
98+
var selectorByMethod = new MethodSelector(TestCase.class,
99+
TestCase.class.getDeclaredMethod("method", int.class, boolean.class));
100+
var selectorByName = new MethodSelector(TestCase.class, "method", int.class, boolean.class);
101+
assertThat(selectorByMethod).isEqualTo(selectorByName);
102+
}
103+
96104
private static class ParentTestCase {
97105

98106
@SuppressWarnings("unused")

0 commit comments

Comments
 (0)