wicket-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Alvizu (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (WICKET-4318) BaseWicketTester#startComponentInPage swallows useful exceptions
Date Thu, 29 Dec 2011 22:48:33 GMT
BaseWicketTester#startComponentInPage swallows useful exceptions
----------------------------------------------------------------

                 Key: WICKET-4318
                 URL: https://issues.apache.org/jira/browse/WICKET-4318
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.5.3
         Environment: JUnit 4.8.2
            Reporter: Dan Alvizu


The method BaseWicketTester#startComponentInPage (final Class<C> componentClass, final
IMarkupFragment pageMarkup) starts a panel inside of page markup through exception, and captures
all of the exceptions (InvocationTargetException, NoSuchMethodException, etc...) in one big
try /catch:

		C comp = null;
		try
		{
			Constructor<C> c = componentClass.getConstructor(String.class);
			comp = c.newInstance(ComponentInPage.ID);
			componentInPage = new ComponentInPage();
			componentInPage.component = comp;
			componentInPage.isInstantiated = true;
		}
		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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message