One of the reasons to have tests is to simplify migrating code
between Prolog implementations. Unfortunately creating a portable
test-suite implies a poor integration into the development environment.
Luckily, the specification of the test-system proposed here can be
ported quite easily to most Prolog systems sufficiently compatible to
SWI-Prolog to consider porting your application. Most important is to
have support for
In the current system, test units are compiled into sub-modules of
the module in which they appear. Few Prolog systems allow for
sub-modules and therefore ports may have to fall-back to inject the code
in the surrounding module. This implies that support predicates used
inside the test unit should not conflict with predicates of the module
The directory of
be in the
library search-path. With PLUNITDIR replaced accordingly,
add the following into your
:- set_prolog_flag(language, iso). % for maximal compatibility
The current version runs under SICStus 3. Open issues:
- Some messages are unformatted because SICStus 3 reports all ISO
errors as instantiation errors.
plunit.pl. Both coverage analysis and the test
generation wizard currently require SWI-Prolog.
normal is the same as
set_test_options(load, never) to avoid loading the test
run option is not supported.
- Tests are loaded into the enclosing module instead of a separate
test module. This means that predicates in the test module must not
conflict with the enclosing module, nor with other test modules loaded
into the same module.