FLAT provides a built-in test framework. It is especially useful to unit-test templates, error handling and upstream requests.
FLAT tests are defined as flow files with the root node
flat-test. There are a couple of specialized test actions that accompany the test flow. The invocation of at least one
assert action is mandatory.
<flat-test><!-- flow code --><assert>[[ … ]]</assert></flat-test>
Test files can be stored anywhere inside the FLAT app directory. We recommend creating a
tests/ folder next to
FLAT tests are started with the
flat cli command
$ flat test tests/test-foo.xml tests/test-bar.xml
The test result is printed in TAP format:
1..2ok 1 tests/test-foo.xml: 17 assertionsok 2 tests/test-bar.xml: 4 assertionspassed: 2, failed: 0
If all tests pass, the exit code is
0. If any test fails, the code is non-zero (
1). Therefore, in deployment scripts or
Makefile recipes (both of which are usually executed as
set -e) you can rely on the exit code to fail the process.