no_error_log

断言错误日志中不包含指定的内容。

语法

--- no_error_log 段确保错误日志中不包含指定的字符串。这是确保没有意外错误的最常用方式。

perl
1=== TEST 1: no errors
2--- config
3 location /t {
4 echo "ok";
5 }
6--- request
7GET /t
8--- response_body
9ok
10--- no_error_log
11[error]
12[alert]
13[emerg]

推荐在每个测试块中都加上 --- no_error_log\n[error] 来捕获意外错误。这是 OpenResty 项目中的最佳实践。