我试图在RT系统上进行单元测试,所以我需要在本地模拟RT实例。基本上,我连接到RT系统,我正在处理车票的队列。有人喜欢代码示例或任何想法吗?我想我需要嘲笑LWP::UserAgent,但我不确定。请给我点主意。提前感谢!
发布于 2017-06-30 21:10:54
下面是我的例子:
my $mock = Test::MockModule->new('REST::Client');
my $raw_response = '';
$mock->mock(
POST => sub { # You can do the same for GET :)
my ($ua, $request) = @_;
if ($request =~ /confirm/) {
$raw_response = $confirm_response_ok; # This is response for Confirm Method in my Code
}
elsif ($request =~ /transfers/) {
$raw_response = $create_response_ok; # This is response for Create transfer in my Code
}
return '';
},
responseCode => sub {
my $self = shift;
return '200';
},
responseContent => sub {
my $self = shift;
return $raw_response;
}
);来自迈阿密的爱。你知道在哪里能找到我们
伊维利奥和哈罗德
https://stackoverflow.com/questions/37163899
复制相似问题