Eunit Expected Exception
Posted
by dagda1
on Stack Overflow
See other posts from Stack Overflow
or by dagda1
Published on 2010-04-12T21:01:16Z
Indexed on
2010/04/12
21:02 UTC
Read the original article
Hit count: 276
Hi,
Is there a way in Eunit to test whether an exception has been thrown under certain cicumstances?
Say I have a function sum like this:
sum(N, M) when N > M ->
throw({"start is bigger than end", N, M});
sum(N, M) when N =:= M ->
N;
sum(N, M) when N =< M ->
N + sum(N + 1, M).
Can I test that if N is bigger than M then an exception is thrown?
Cheers
Paul
© Stack Overflow or respective owner