For automation, there's a logtalk_tester
Bash shell script included in the Logtalk distribution that gives you a single summary. For running all tests for all loaded objects extending lgtunit
, a partial solution could be a goal such as:
?- forall(extends_object(TestObject, lgtunit), TestObject::run).
But this will not give you a single summary. A solution is to define a summary object defining the logtalk::message_hook/4
hook predicate to intercept and collect all relevant information and then to summarize it. You can check the message terms in the lgtunit/lgtunit_messages.lgt
file. The one that you want to intercept is tests_results_summary(Total, Skipped, Passed, Failed, Note)
. Something like:
:- object(test_summary).
:- public(report/0).
report :-
% compute totals from result_/4 and report them
...
:- private(result_/4).
:- dynamic(result_/4).
:- multifile(logtalk::message_hook/4).
:- dynamic(logtalk::message_hook/4).
logtalk::message_hook(tests_results_summary(Total,Skipped,Passed,Failed,_), _, lgtunit, _) :-
assertz(result_(Total,Skipped,Passed,Failed)).
:- end_object.
Possibly, also add a run_all/0
predicate to this object using e.g. the solution above. The multifile predicate is also dynamic. Thus, you can assert and retract its definition so that it would only be active when you want to run all tests and summarize the results.
Btw, a fully developed and document solution along the lines above would make a nice contribution to Logtalk...