[Mono-dev] Example of an expected execption test

Alan McGovern alan.mcgovern at gmail.com
Fri Mar 9 05:01:15 EST 2007


[Test]
[ExpectedException(typeof(StupidException))]
public void TestStupidException()
{
      throw new StupidException();
}

The above test should pass (unless i've done it wrong ;) ).You can also
check to make sure the message is the same by doing the following:


[Test]
[ExpectedException(typeof(StupidException), Message="You forgot to catch the
stupid exception")]
public void TestStupidException()
{
      throw new StupidException("You forgot to catch the stupid exception");
}


On 3/9/07, Dennis Hayes <denisraytek at yahoo.com> wrote:
>
> Can someone point me to a Mono test case that checks for an expected
> execption?
> Dennis
>
>
> ------------------------------
> Don't be flakey. Get Yahoo! Mail for Mobile<http://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mail>and
> always stay connected<http://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mail>to friends.
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070309/295445f5/attachment.html 


More information about the Mono-devel-list mailing list