Skip to content

Commit

Permalink
Only invoke public no args callbacks in Arquillian testing
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Jun 14, 2023
1 parent 65aad80 commit eb5c707
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ static void invokeJunitBefores(String className, Object testInstance)
collectCallbacks(testInstance.getClass(), befores, (Class<? extends Annotation>) testInstance.getClass()
.getClassLoader().loadClass(className));
for (Method before : befores) {
before.invoke(testInstance);
if (before.canAccess(testInstance) && before.getParameters().length == 0) {
before.invoke(testInstance);
}
}
}
}
Expand All @@ -35,7 +37,9 @@ static void invokeJunitAfters(String className, Object testInstance)
collectCallbacks(testInstance.getClass(), afters, (Class<? extends Annotation>) testInstance.getClass()
.getClassLoader().loadClass(className));
for (Method after : afters) {
after.invoke(testInstance);
if (after.canAccess(testInstance) && after.getParameters().length == 0) {
after.invoke(testInstance);
}
}
}
}
Expand Down

0 comments on commit eb5c707

Please sign in to comment.