Writing tests
The preferred testing framework for Kong is running with the resty-cli interpreter, though you are free to use a different one. In the Kong repository, the busted executable can be found at .
Kong provides you with a helper to start and stop it from Lua in your test suite: spec.helpers
. This helper also provides you with ways to insert fixtures in your datastore before running your tests, as well as dropping it, and various other helpers.
Assuming that the spec.helpers
module is available in your , you can use the following Lua code in busted to start and stop Kong:
With the test Kong configuration file, Kong is running with its proxy listening on port 9000 (HTTP), 9443 (HTTPS) and Admin API on port 9001.
Previous