Commit 8e4ae954 authored by Adam Blank's avatar Adam Blank
Browse files

Add better error message to failure based on accidental public method.

parent 68cf02e8
No related merge requests found
Pipeline #77290 failed with stage
in 0 seconds
Showing with 15 additions and 9 deletions
+15 -9
...@@ -131,16 +131,22 @@ public interface IStyleTests { ...@@ -131,16 +131,22 @@ public interface IStyleTests {
} }
if (Modifier.isPublic(m.getModifiers())) { if (Modifier.isPublic(m.getModifiers())) {
for (int i = 0; i < 100; i++) { try {
if (m.getParameterCount() == 0) { for (int i = 0; i < 100; i++) {
m.invoke(o); if (m.getParameterCount() == 0) {
} else if (m.getParameterCount() == 1) { m.invoke(o);
Class<?>[] clazes = m.getParameterTypes(); } else if (m.getParameterCount() == 1) {
m.invoke(o, getArg(clazes[0])); Class<?>[] clazes = m.getParameterTypes();
} else if (m.getParameterCount() == 2) { m.invoke(o, getArg(clazes[0]));
Class<?>[] clazes = m.getParameterTypes(); } else if (m.getParameterCount() == 2) {
m.invoke(o, getArg(clazes[0]), getArg(clazes[1])); Class<?>[] clazes = m.getParameterTypes();
m.invoke(o, getArg(clazes[0]), getArg(clazes[1]));
}
} }
} catch (IllegalArgumentException e) {
System.out.println("You have a method that should be private that is public.");
System.out.println("Take a look at your method: " + m);
throw e;
} }
} }
assertTrue(NewMe.NUM_CALLS == 0, "Calls to " + m.getName() + " should not create a new instance of " + getClazz().getName()); assertTrue(NewMe.NUM_CALLS == 0, "Calls to " + m.getName() + " should not create a new instance of " + getClazz().getName());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment