better openresty busted test unit framework
resty [resty_options...] rebusted2 [busted_options...] [busted_files...]
rebusted2 [busted_options...] [busted_files...]
launch.json
{
"type": "lua",
"request": "launch",
"name": "Debug",
"program": "${file}",
"luaexe": "resty",
"arg0": ["-e","require 'resty.busted2'({standalone=false})"],
"luaVersion": "jit",
"cpath": null,
"path": null,
}
The ngx.log output can now be inspected.
it('DEBUG', function()
ngx.log(ngx.DEBUG, '1')
assert.error_log('1', ngx.DEBUG)
end)
Notice
:
CRIT
,ALERT
,EMERG
will throw errorSTDERR
will just output to std err
default
log level is ngx.ERR
, changed by
assert:set_parameter('default_ngx_log_level', ngx.DEBUG)
start a new describe
,context
,file
,suite
test.
If you want to clean up in every test.
context('every test clear log', function()
busted_ngx.each_test_clean_log()
ngx.log(ngx.ERR, '1')
it('1', function()
assert.no.error_log()
end)
it('2', function()
assert.no.error_log('1')
ngx.log(ngx.ERR, '2')
assert.error_log('2')
end)
end)