简体   繁体   中英

How to run perl xt tests?

Lately the new great thing appeared in the Perl world. For a long time in the library package there was folder t that contained tests. Now there is one more folder xt that contains author test. 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.

There is a spript prove that ships with the Perl that runs test. If you run prove without parameters all tests from the folder 't' will be executed. If you want to run both t and xt test you should write:

prove xt t

It it possible to add to the configuration file .proverc file that parameters ( xt t ). Then when you run prove without parameters they will be taken from file and tests in the both folders will be executed.

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 . If you say prove t/00-load.t it will execute all the tests in both folders, because it takes parameters from config file. You need to write prove --norc t/00-load.t . But this seems ugly.

How do you run your xt tests?

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. 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.

I sometimes use Dist::Zilla , which handles author tests by default.

I add

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

to Makefile.PL . This runs the normals tests, and then the xt tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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