test-nginx
test-nginx copied to clipboard
[question]running tests fail
hi, I run the example in https://openresty.gitbooks.io/programming-openresty/content/testing/running-tests.html, then get this failed result:
t/foo.t ..
ok 1 - TEST 1: hello, world - status code ok
not ok 2 - TEST 1: hello, world - response_body - response is expected (repeated req 0, req 0)
# Failed test 'TEST 1: hello, world - response_body - response is expected (repeated req 0, req 0)'
# at /Library/Perl/5.18/Test/Nginx/Socket.pm line 1387.
# got: "hello, world!\x{0a}"
# length: 14
# expected: "hello, world!\x{0a}--- error_code: 200"
# length: 33
# strings begin to differ at char 15 (line 2 column 1)
1..2
# Looks like you failed 1 test of 2.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
Test Summary Report
-------------------
t/foo.t (Wstat: 256 Tests: 2 Failed: 1)
Failed test: 2
Non-zero exit status: 1
Files=1, Tests=2, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.12 cusr 0.04 csys = 0.18 CPU)
Result: FAIL
I don't know what's the reason, please help me fix it. Thank you!
Hey, if its is still relevant:
use no_long_string(); just before you call run_tests();
@pangfeng Make sure there is at least one newline character at the end of your .t file. That error message is a clear indication for the lack of newline character right after the --- error_code: 200 line.