- The Prototype
There exists one test project for each cultivate project. Additionally you need to checkout the cultivate.testframework platform project , which contains common files for all tests.
The following directories may exist in each test project:
For writing prolog tests take a look at the demo.APITest example class in cultivate.basic.test:
Creation of a new test consists of 4 steps:
First you need to write your testdata. Do this by creating a new testdata-* src folder and adding it to the build path. Now write your packages and classes. Afterwards you must run the generator-factbases-project.launch via the eclipse launcher menu. This will create the file *.qlf in the factbases directory. Now you can write your test by extending the AbstractPrologTestCase. It will automatically consult the prolog file prolog/load.pl of your project.
The framework supports hamcrest matcher, which should be used. See the Class APITest.java in *cultivate.basic.test/prolog-test/demo/APITest.java*
uses queryOnce and gives only the unifications for one call of the predicate.
uses queryAll, gives all results of the predicate through backtracking
returns a PEF Id for the given full qualified name, see the prolog documentation of id_of_named_element/3 for details.
calls the predicate without giving results (only success), useful for calling a generation predicate.
The basic Matcher are contained in the CultivateMatcher and the Hamcrest Matchers factory classes.
The following list is taken from the official hamcrest website (May 2011).
The following methods are deprecated and should not be used.
Additionally you have the following helper methods to use:
For executing predicates in a changing context, the
ContextualPredicate class is provided. it supports the following methods: