Did you know ... Search Documentation:
Pack doctest -- README.md

Doctest

![Latest release](https://gitlab.inria.fr/soliman/doctest/-/releases) ![Build Status](https://gitlab.inria.fr/soliman/doctest/-/pipelines)

Features

Generate PlUnit tests from queries in the PlDoc documentation of your module.

Be careful, this uses (and will run) the queries only (identified by ?- ) and not the documented answers (it will instead identify all answers/errors/etc. thanks to the test_wizard library) unless you use the parse_output(true) option. However that option currently will not properly recognize exception messages…

In all cases, if your queries call use_module, or print some output via write they will probably crash the parser. To avoid this, use indented code blocks, these will be safely ignored.

The current handling of errors is… work in progress ;)

Install

swipl pack install doctest

Usage

?- use_module(library(doctest)).
?- gen_doctests('input.pl', [outfile('output.plt')]).

You can access this package's PlDoc at https://soliman.gitlabpages.inria.fr/doctest/prolog/doctest.html