PlUnit is a unit testing library for Prolog. Its goals are:
- provide a more expressive and familiar API for PlUnit by implementing xUnit-like test predicates such as
assert_true/1andassert_type/2 - provide significantly more helpful and user-friendly feedback on test fail
- full compatibility with PlUnit: you can still use
assertion/1if you wish
Whilst this wasn't an explicit design goal initially, another benefit of plunit_assert is:
- it can easily be leveraged by calling its test predicates directly within the Prolog REPL, which can be a trying experience with manual calls to
assertion/1.
See this in action under Examples below.
The API documentation is generated by PlDoc and the latest is always available here:
https://simonharris.github.io/plunit_assert/
Packages are hosted here:
https://packages.pointbeing.net/plunit_assert/
Thus, the current version of the library can be installed using:
?- pack_install(plunit_assert, [url('https://packages.pointbeing.net/plunit_assert/plunit_assert-0.2.1.tgz')]).
It is also discoverable via pack_list/1:
?- pack_list(plunit_assert).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
p [email protected] - An expressive xUnit-like API for PlUnit with more helpful fail messages
true.
?- pack_install(plunit_assert).
...etc...
?- assert_type(3.0, boolean).
[plunit_assert] Asserted 3.0 is of type 'boolean' but got 'float'
false.
?- assert_equals(3+1, 4).
true.
?- assert_is(3+1, 4).
[plunit_assert] Asserted identity but 3+1 and 4 are not identical
false.
?- assert_lte(3^7, 6+9.6).
[plunit_assert] Comparison failed: 3^7 (2187) is not less than or equal to 6+9.6 (15.6)
false.