Web 与单元测试全解析:从 Apache 到 Test::Class
1. Apache::Test 搭配其他测试模块
在使用 Apache::Test 时,是可以搭配其他测试模块的。只需在使用 Apache::Test 时提供 -withtestmore 参数,这样 Test::More 的所有函数就能立即使用。示例代码如下:
#!perl
use strict;
use warnings;
use Apache::Test qw(-withtestmore);
use Apache::TestUtil;
use Apache::TestRequest qw( GET_BODY );
use Imager;
plan( tests => 1, need_module('mod_perl') );
my $content = GET_BODY('/images/panorama.jpg');
my $img = Imager->new( );
$img->open( data => $content, type => 'jpeg' )
or die $img->errstr( );
my $max = 150;
diag( 'assuming constraint is $max pixels' );
diag( 'width: ' . $img->getwidth( ) );
diag( 'height: ' . $img->getheight( ) );
ok( ( $img->getwidth( ) == $max
超级会员免费看
订阅专栏 解锁全文
168万+

被折叠的 条评论
为什么被折叠?



