How would I write a test for this Prolog rule?
rule(5,jasmine_tea):- symptom(high_cholesterol),symptom(delicate_fragrance).
High Performance Mark - this is what I've got.
FACTS:
question('Do you suffer from anxiety?',anxiety).
symptom(anxiety).
reply(chamomile_tea,'Drink 3 cups of Chamomile tea everyday for a week.').
RULES:
rule(1,chamomile_tea):- symptom(anxiety),symptom(no_sleep).
Hope that makes things a bit clearer.
There are several unit testing tools that you can use. In SWI-Prolog, you have "plunit":
http://www.swi-prolog.org/pldoc/doc_for?object=section('packages/plunit.html')
Logtalk provides you an alternative (and portable) tool, that you can use with SWI-Prolog and other Prolog systems:
https://github.com/LogtalkDotOrg/logtalk3/blob/master/tools/lgtunit/NOTES.md
In both cases, there's abundant documentation and example on how to write unit tests. In a nutshell, you specify a test goal and the expected outcome (success with expected bindings, failure, error and the expected exception term). You also specify (implicitly or explicitly) the environment for the test run (e.g. setup and cleanup goals or database contents).