By convention, a test suite corresponds to a library module in your application. To get started, create a directory under src/test/suites/ named for your library module.
Inside your test suite, you can create four specially-named files:
setup.sjs- This module will be run before each test in your suite. Here you might insert documents into the test database that each of your tests will modify.
teardown.sjs- This module will run after each test in your suite. You might use this module to remove the documents inserted by
suiteSetup.sjs- Run once when your suite is started. You can use this to insert some data that will not be modified over the course of the suite’s tests.
suiteTeardown.sjs- Run once when your suite is finished, to clean up after the suite’s tests.
MarkLogic Unit Test will assume any other files in your test suite directory are tests. Typically, a module has responsibility for testing a particular function.
You can also create subdirectories in your test suite. The testing component will ignore these, so they are a good
place for supporting files, like test data. Test data should be placed in a subdirectory called
As an example, consider a hypothetical library module that converts Comma Separated Values (CSV) to XML called
csv-lib.xqy. Let’s suppose it has a function called convert. We might test that with files like the following:
lib.xqy library file would be a library module that defines variables usable across the setup, teardown, and test
modules. For instance, it could define a
$URI variable that indicates where the test data are inserted in the