Testing
FLAT provides a built-in test framework. It is especially useful to unit-test templates, error handling and upstream requests.
Syntax
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.
Directories
Test files can be stored anywhere inside the FLAT app directory. We recommend creating a tests/
folder next to swagger.yaml
.
Command
FLAT tests are started with the flat
cli command test
:
The test result is printed in TAP format:
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.
See also
Testing Templates (cookbook)
Testing API Requests (cookbook)
Testing Upstream Requests (cookbook)
Test Actions (reference)
assert
(reference)backend-flow
(reference)set-env
(reference)test-request
(reference)
Last updated