Unity: Ariadne Unit Tests
This library is a simple unit testing framework for PINP libraries. It is not meant to be used as a monitoring tool, use the Health checks library for that instead.
To do this, the library defines a template health.run which can be called on the psite.health root of the health checks. This template will output / echo 'OK' if all checks ar ok. If any check fails, it will display all errors encountered in all tests.
To set this up, load this library unnamed:
Create a new pdir.unity named 'tests' in your library. The library makes this type available under the psection.lib subtype.
Create templates which start with the name 'unity.test.' to make an automatic unit test. These will be called automatically whenever a full unit test is run. A succesfull test must return TRUE. Any other return value will be seen as an error and displayed. Any exceptions thrown and not caught will also fail the test.
If you create a template which starts with 'unity.manual.', the template will be listed in the 'manual tests' section and will not be automatically run. These templates are meant for tests that are difficult to automate but need a human check. You can create html output in them and any return value will be displayed below the template output.
Unity support setup / teardown through the
unity.teardown templates. Define these on the
pdir.unity type, in your unit
test directory. The setup template can return an array with data, which will be passed to each test template. The result of the teardown
template isn't used. The teardown template is also called with all the data from the setup template.
You can run the tests manually by clicking on 'View webpage' in the unity directory from the Ariadne UI. You can also call them remotely by
calling the template
unity.run.html for the html output or
unity.run.json which will return the test data as json.