From: "Wannheden, Knut" <[EMAIL PROTECTED]>
> 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.

This sounds like a great idea! It'll sure simplify many JellyUnit scripts.
Fancy having a go at implementing it?

Maybe you could allow the exception to be exported so that further tests
could be made. e.g.

<test:assertFails var="ex">
    ...
</test:assertFails>
<test:assertTest test="${ex.message.startsWith('Cannot delete foo ')}"/>

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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

Reply via email to