????????????????Nginx??Test::More?÷?
???????????? ???????[ 2013/6/14 15:49:10 ] ????????
????Perl ???????????????Test::More ???e??????????????????????????????Test::Unit?????????Test::Nginx???????????????鴴??????????????????鳣?????á?
????1???????????
????use Test::More;
??????Test::More??????????????????? testcase ?????????????????£?
????use Test::More tests => 2;
??????????????????????????????????С?
???????????????ж??????????????У????????????????
????use Test::More; # see done_testing()
????……
??????в???????
????……
????done_testing(); or done_testing($number_of_tests_run);
????2?????? Test::More ?????????
????ok
ok($succeeded?? $test_name);
?????÷????????ж?????????????????????????ж?????????????????????????????????$succeeded ???????????????0????????????????????????????÷?????£?
ok( $exp{9} == 81?? 'simple exponential' );
ok( Film->can('db_Main')?? 'set_db()' );
ok( $p->tests == 4?? 'saw tests' );
ok( !grep !defined $_?? @items?? 'items populated' );
????is/isnt
is ( $got?? $expected?? $test_name );
is ( $got?? $expected?? $test_name );
????is() ?? isnt()??????ok()??????????????is() ?? isnt()??????????????????????????ò????????????????????isnt()??????is()??????????÷???
# Is the ultimate answer 42?
is( ultimate_answer()?? 42?? "Meaning of Life" );
# $foo isn't empty
isnt( $foo?? ''?? "Got some foo" );
????????ok()??????
ok( ultimate_answer() eq 42?? "Meaning of Life" );
ok( $foo ne ''?? "Got some foo" );
???????undef ??????undef??
????Like/ unlike
like( $got?? qr/expected/?? $test_name );
unlike( $got?? qr/expected/?? $test_name );
?????ú?????ok()????????????????????????????????????qr/expected/??unlike()?like()??????????????÷???
like($got?? qr/expected/?? 'this is like that');
???????????
ok( $got =~ /expected/?? 'this is like that');
????cmp_ok
cmp_ok( $got?? $op?? $expected?? $test_name );
????cmp_ok()??????????ok() ?? is()???÷?????????????????????????÷???
cmp_ok( $got?? 'eq'?? $expected?? 'this eq that' );
cmp_ok( $got?? '=='?? $expected?? 'this == that' );
cmp_ok( $got?? '&&'?? $expected?? 'this && that' );
????3????????????????????????
??????????????????????????????????????????debug?????????????????Щ??????????е?????????????????????????????
????diag
diag(@diagnostic_message);
?????ú????????????????????????????????. ?????в??????????????????????÷?????£?
ok( grep(/foo/?? @users)?? "There's a foo user" ) or
diag("Since there's no foo?? check that /etc/bar is set up right");
????explain
my @dump = explain @diagnostic_message;
?????ú?????????????????????????κ???????????????????diag()?????????á?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11