Skip to content

Commit fe2832e

Browse files
committed
Add missing tests for ReflectionSupport.findMethod()
1 parent 94feef1 commit fe2832e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

platform-tests/src/test/java/org/junit/platform/commons/support/ReflectionSupportTests.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,36 @@ void tryToReadFieldValuePreconditions() throws Exception {
224224
.hasMessageEndingWith("on a null instance.");
225225
}
226226

227+
@Test
228+
void findMethodDelegates() throws Exception {
229+
assertEquals(ReflectionUtils.findMethod(Boolean.class, "valueOf", String.class.getName()),
230+
ReflectionSupport.findMethod(Boolean.class, "valueOf", String.class.getName()));
231+
232+
assertEquals(ReflectionUtils.findMethod(Boolean.class, "valueOf", String.class),
233+
ReflectionSupport.findMethod(Boolean.class, "valueOf", String.class));
234+
}
235+
236+
@Test
237+
void findMethodPreconditions() throws Exception {
238+
assertPreconditionViolationException("Class",
239+
() -> ReflectionSupport.findMethod(null, "valueOf", String.class.getName()));
240+
assertPreconditionViolationExceptionForString("Method name",
241+
() -> ReflectionSupport.findMethod(Boolean.class, "", String.class.getName()));
242+
assertPreconditionViolationExceptionForString("Method name",
243+
() -> ReflectionSupport.findMethod(Boolean.class, " ", String.class.getName()));
244+
245+
assertPreconditionViolationException("Class",
246+
() -> ReflectionSupport.findMethod(null, "valueOf", String.class));
247+
assertPreconditionViolationExceptionForString("Method name",
248+
() -> ReflectionSupport.findMethod(Boolean.class, "", String.class));
249+
assertPreconditionViolationExceptionForString("Method name",
250+
() -> ReflectionSupport.findMethod(Boolean.class, " ", String.class));
251+
assertPreconditionViolationException("Parameter types array",
252+
() -> ReflectionSupport.findMethod(Boolean.class, "valueOf", (Class<?>[]) null));
253+
assertPreconditionViolationException("Individual parameter types",
254+
() -> ReflectionSupport.findMethod(Boolean.class, "valueOf", new Class<?>[] { null }));
255+
}
256+
227257
@Test
228258
void findMethodsDelegates() {
229259
assertEquals(

0 commit comments

Comments
 (0)