Previous: , Up: PlUnit A Unit Test Box   [Contents][Index]


10.29.3.4 Tests Expected to Raise Exceptions

Tests that are expected to raise exceptions may be specified using the option exception(Expected) or one of its equivalents, or by wrapping the test in on_exception/3 or catch/3. The following tests are equivalent:

test(div01) :-
     on_exception(Excp, A is 1/0, true),
     subsumes_term(error(evaluation_error(zero_divisor),_), Excp).

test(div02, [error(evaluation_error(zero_divisor))]) :-
     A is 1/0.

test(div03, [error(evaluation_error(zero_divisor),_)]) :-
     A is 1/0.

test(div04, [exception(error(evaluation_error(zero_divisor),_))]) :-
     A is 1/0.

test(div05, [throws(error(evaluation_error(zero_divisor),_))]) :-
     A is 1/0.

Send feedback on this subject.