PLUnit - summary report

Hi

I am using PLUnit to run some tests, but I am missing a bit…

How do I get a “summary” of the tests run? That is, the number of tests that succeeded, the number of tests that failed, etc etc.

I have seen test_report/1, but it does not appear to either work or doing what I need.

Any ideas about how to go ahead to obtain this information without cluttering the code with setup and cleanup clauses?

Thanks
Marco Antoniotti

By default, it does e.g.,

swipl ../src/Tests/tabling/test_tabling.pl 
...
101 ?- test_tabling.
% PL-Unit: tabling_ex1 . done
% PL-Unit: tabling_ex2 . done
% PL-Unit: tabling_ex3 . done
...
% PL-Unit: mode_components1 . done
% PL-Unit: mode_components2 . done
% All 32 tests passed
true.

If tests are failing it should also report these and the test goal fails. If you use -q, it only reports a . on each passed test.

All output is passed through print_message/2 though. This predicate can be hooked, doing whatever you like with the output. See Anne Ogborn’s tutorial at http://www.pathwayslms.com/swipltuts/message/index.html

See the source for plunit.pl for the many message formats used to print all the test events.

Ok. Thanks. I see that kind of output, but I need to actually have a handle on each variable.

I’ll have a look at the pointers.

All the best

MA

In theory you can use the message hook to assert all the information you need and succeed without printing anything. Then at the end you collect everything and write the report you want to write.

Would be nice to have a message implementation that is compatible with e.g., TAP. If you plan to write something like that, please share.

I remembered coming across this, may be useful

1 Like