I'm having difficulty getting plunit
to execute tests in seeemingly the most trivial case. Here's my setup:
x(5) :- !.
not(x(6)).
:- begin_tests(foo).
test_something(x) :- not(x(5)).
test_seomthing_else(x) :- x(6).
:- end_tests(foo).
This works as expected in swipl:
?- [foo].
% foo compiled 0.00 sec, 3 clauses
true.
?- x(5).
true.
?- x(6).
false.
But I can't seem to get the foo.plt file to fail
?- load_test_files(foo).
% /tmp/example/foo.plt compiled into plunit 0.00 sec, 4 clauses
true.
?- run_tests.
% PL-Unit: foo done
% No tests to run
true.
The test_something_else
testcase should clearly be failing, but plunit's run_tests/0
seems unaware there are any tests to run.
From the plunit manual:
The entry points are defined by rules using the head test(Name) or test(Name, Options) [...]
So instead of having test_something(x)
and test_something_else(x)
, you need to simply use test(x)
.
:- begin_tests(foo).
test(x) :- not(x(5)).
test(x) :- x(6).
:- end_tests(foo).
Running this will give the expected output:
?- run_tests.
% PL-Unit: foo
ERROR: [...]
test x: failed
ERROR: [...]
test x: failed
done
% 2 tests failed
% 0 tests passed
false.