有Perl好的自动测试套件吗? [英] Are there any good automated test suites for Perl?

查看:75
本文介绍了有Perl好的自动测试套件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以为Perl建议一些好的自动化测试套件框架吗?

Can someone suggest some good automated test suite framework for Perl?

推荐答案

这确实取决于您要尝试执行的操作,但这是其中的大部分背景.

It really depends on what you're trying to do, but here's some background for much of this.

首先,通常会使用Test :: More或Test :: Simple作为核心测试程序来编写测试程序:

First, you would generally write your test programs with Test::More or Test::Simple as the core testing program:

use Test::More tests => 2;

is 3, 3, 'basic equality should work';
ok !0, '... and zero should be false';

在内部,调用Test :: Builder以将那些测试结果输出为TAP(测试任何协议). Test :: Harness(围绕TAP :: Harness的薄包装),读取和解释TAP,并告诉您测试是否通过或失败.上面提到的证明"工具与Test :: Harness捆绑在一起,因此,可以将上面的代码保存在t/目录(标准Perl测试目录)中作为"numbers.t",然后可以使用以下命令运行它:

Internally, Test::Builder is called to output those test results as TAP (Test Anything Protocol). Test::Harness (a thin wrapper around TAP::Harness), reads and interprets the TAP, telling you if your tests passed or failed. The "prove" tool mentioned above is bundled with Test::Harness, so let's say that save the above in the t/ directory (the standard Perl testing directory) as "numbers.t", then you can run it with this command:

prove --verbose t/numbers.t

或者运行该目录中的所有测试(递归地,假设您想进入子目录):

Or to run all tests in that directory (recursively, assuming you want to descend into subdirectories):

prove --verbose -r t/

(-verbose当然是可选的).

(--verbose, of course, is optional).

请注意,请勿使用TestUnit.很多人推荐它,但是很久以前就放弃了它,并且不与现代测试工具集成.

As a side note, don't use TestUnit. Many people recommend it, but it was abandoned a long time ago and doesn't integrate with modern testing tools.

这篇关于有Perl好的自动测试套件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆