Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.5.3
-
None
-
JUnit 4.8.2
Description
The method BaseWicketTester#startComponentInPage (final Class<C> componentClass, final IMarkupFragment pageMarkup) starts a panel inside of page markup through reflection, and captures all of the exceptions (InvocationTargetException, NoSuchMethodException, etc...) in one big try /catch:
C comp = null;
try
catch (Exception e)
{ fail(e.getMessage()); }There are two issues with this:
1) This fail() will often not print out anything helpful about the exception that caused the error. For a NullPointerException (along with many other exceptions) you'll simply get back: "junit.framework.AssertionFailedError: null"
2) You cannot write tests that expect an exception in the constructor, for example if you were using auth-roles and expect to see an UnauthorizedInstantiationException if you provide the wrong role, you cannot test this. You could test this scenario if it were a page, however, because these Exceptions will not be swallowed.