简体   繁体   English

如何运行perl xt测试?

[英]How to run perl xt tests?

Lately the new great thing appeared in the Perl world. 最近,新的伟大事物出现在Perl世界中。 For a long time in the library package there was folder t that contained tests. 在库包中很长一段时间都有包含测试的文件夹t Now there is one more folder xt that contains author test. 现在还有一个包含作者测试的文件夹xt The xt tests are not needed in the process of the library installation, but it helps library autor to make sure that the code is great. 在库安装过程中不需要xt测试,但它有助于库autor确保代码很好。

There is a spript prove that ships with the Perl that runs test. 有一个spript prove与Perl一起运行测试。 If you run prove without parameters all tests from the folder 't' will be executed. 如果运行不带参数的prove ,将执行文件夹't'中的所有测试。 If you want to run both t and xt test you should write: 如果你想同时运行txt测试你应该写:

prove xt t

It it possible to add to the configuration file .proverc file that parameters ( xt t ). 它可以添加到配置文件.proverc文件中的参数( xt t )。 Then when you run prove without parameters they will be taken from file and tests in the both folders will be executed. 然后,当您运行不带参数的prove ,它们将从文件中获取,并且将执行两个文件夹中的测试。

But here comes the problem. 但问题来了。 In case you have xt t in your .proverc file you can't just pass the filename as the parameter to the prove . 如果您在.proverc文件中有xt t ,则不能将文件名作为参数传递给prove If you say prove t/00-load.t it will execute all the tests in both folders, because it takes parameters from config file. 如果你说prove t/00-load.t它将执行两个文件夹中的所有测试,因为它从配置文件中获取参数。 You need to write prove --norc t/00-load.t . 你需要编写prove --norc t/00-load.t But this seems ugly. 但这看起来很难看。

How do you run your xt tests? 你如何运行xt测试?

Author tests should not be run by default - you don't want a CPAN install to fail because some of your POD syntax is wrong. 默认情况下不应运行作者测试 - 您不希望CPAN安装失败,因为您的某些POD语法错误。 They should ideally be run on release, when specifically requested. 理想情况下,在特别要求时,它们应该在发布时运行。

See http://elliotlovesperl.com/2009/11/24/explicitly-running-author-tests/ for a method involving Module::Build. 有关涉及Module :: Build的方法,请参见http://elliotlovesperl.com/2009/11/24/explicitly-running-author-tests/

I sometimes use Dist::Zilla , which handles author tests by default. 我有时使用Dist :: Zilla ,它默认处理作者测试。

I add 我加

package MY;
sub depend {
  "
xtest :: test
    \$(MAKE) test TEST_FILES=xt/*.t
"
}

to Makefile.PL . Makefile.PL This runs the normals tests, and then the xt tests. 这将运行法线测试,然后运行xt测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM