Previous: PlUnit Tests Expected to Fail, Up: PlUnit A Unit Test Box [Contents][Index]
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) :- catch(A is 1/0, Excp, 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.