【问题标题】:How to do unit testing with busted in openresty?如何在 openresty 中使用 busted 进行单元测试?
【发布时间】:2014-10-12 17:35:59
【问题描述】:

我有一堆 lua 文件,用于处理 nginx 中的不同 url,如下所示:

location /tag {
    set $env       'prod';
    set $redis_ttl 7776000;
    content_by_lua_file 'conf/match.lua';
    log_by_lua_file     'conf/log.lua';
}

每个文件都是一个简单的脚本,没有任何模块结构。当行数和文件数很少时,我手动测试了所有内容,但现在我觉得我需要进行单元测试。 Busted 框架看起来是一个合乎逻辑的选择,虽然我不明白如何将它直接融入 openresty 模型。

【问题讨论】:

    标签: unit-testing nginx lua openresty lua-busted


    【解决方案1】:

    不过,我对 Busted 并不是很熟悉, 如果您对使用 Perl 足够熟悉; Openresty的作者有一个专门测试nginx-lua的测试脚手架,代码命名为:Test::Nginx::Socket::Lua

    您可以找到CPAN module heresource code here

    【讨论】:

      猜你喜欢
      • 2022-10-20
      • 2018-07-02
      • 1970-01-01
      • 2012-01-08
      • 2021-03-15
      • 2014-01-12
      • 2020-01-06
      • 2021-11-16
      • 2019-12-11
      相关资源
      最近更新 更多