Hi,

The well known Java pattern used to assert exceptions are thrown:

try {
        // run some code that should throw an exception
        fail("We should have created an exception");
} catch (Exception e) {
}

seems commonly to be translated like this in Jelly:

<j:catch var="ex">
 <test:fail message="This should always fail"/>
</j:catch>
<test:assert test="${ex != null}">
 We should have created an exception
</test:assert>

I was thinking it would be nice with a new tag or some macro tag which does
this.  Maybe something like:

<test:assertFails>
 <test:fail>This should always fail</test:fail>
</test:assertFails>

Of course different forms of this could be useful too:

<test:assertFails expectedException="junit.framework.AssertionFailedError">
 <test:fail>This should always fail</test:fail>
</test:assertFails>

or:

<test:assertFails messageFormat="Something went wrong here: ${ex.message}">
        <test:fail>This should always fail</test:fail>
</test:assertFails>

I think it would be especially nice because the exception catching and
handling wouldn't be disconnected anymore.

Comments?

--
knut

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to