我很难让plunit在最琐碎的情况下执行测试。这是我的装置:
foo.pl
x(5) :- !.
not(x(6)).foo.plt
:- begin_tests(foo).
test_something(x) :- not(x(5)).
test_seomthing_else(x) :- x(6).
:- end_tests(foo).这与swipl中所期望的一样工作:
?- [foo].
% foo compiled 0.00 sec, 3 clauses
true.
?- x(5).
true.
?- x(6).
false.但我似乎不能让foo.plt文件失败
?- 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.显然,test_something_else测试用例应该失败了,但是plunit的run_tests/0似乎不知道有什么测试要运行。
发布于 2015-11-22 10:08:27
来自机组手册
入口点由使用头测试(名称)或测试(名称、选项)的规则定义.
因此,您不需要使用test_something(x)和test_something_else(x),而只需使用test(x)。
:- begin_tests(foo).
test(x) :- not(x(5)).
test(x) :- x(6).
:- end_tests(foo).运行这将给出预期的输出:
?- run_tests.
% PL-Unit: foo
ERROR: [...]
test x: failed
ERROR: [...]
test x: failed
done
% 2 tests failed
% 0 tests passed
false.https://stackoverflow.com/questions/33852800
复制相似问题