如何在 Perl 发行版中仅运行特定测试? [英] How can I run only a specific test in a Perl distribution?

查看:69
本文介绍了如何在 Perl 发行版中仅运行特定测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题与这个问题有关之前.我创建了多个测试文件(A.t、B.t、C.t 等)来测试它们各自的模块 A、B、C &很快.但是当我进行 make 测试时,它会运行所有测试.但是,当我处理一个特定的模块时,比如 B,我想为那个模块运行单元测试.完成更改后,我将运行整个套件.

This question is related to this question I asked before. I have multiple test files (A.t, B.t, C.t etc) created to test their respective module A, B, C & so on. But when I do a make test, it runs all the tests. But, when I'm working on a specific module say B, I'd like to run unit tests for that module. After I'm done with my changes, I'll run the whole suite.

那么有没有什么办法可以像make test B那样只运行使用B.t的测试?当我说make test all"之类的东西时,它会在t"目录下运行所有​​测试?谢谢.

So is there any way to do like make test B, which will run only the tests using B.t? And when I say some thing like "make test all" it runs all the tests under the "t" dir? Thanks.

推荐答案

我只是运行了我想运行的测试:

I just run the test that I want to run:

 % make; perl -Mblib t/B.t

你也可以用 prove 做同样的事情.

You can do the same thing with prove, too.

那个 -Mblib 加载模块 blib 只添加blib/lib(以及其下的各种特殊目录)到 @INC 为您服务.它带有 Perl.prove 应该用 -b 开关做同样的事情.

That -Mblib loads the module blib which merely adds blib/lib (and various special directories under it) to @INC for you. It comes with Perl. prove should do the same thing with the -b switch.

我的命令实际上是两部分:make(或 ./Build 用于 模块::构建).这会构建源代码并将 Perl 模块和其他文件移动到构建库"或 blib 中,作为完整安装的中间步骤.通常 make testblib 中的版本起作用并为我刷新它.由于我是自己测试,因此我确保自己刷新 blib 并将其包含在 Perl 的模块搜索路径中.

My command is really two parts: the make (or ./Build for Module::Build). This builds the source and moves Perl modules and other files into the "build library", or blib, as an intermediate step in the full installation. Normally make test works against the versions in blib and refreshes that for me. Since I'm testing on my own, I ensure that I refresh blib myself and include it in Perl's module search path.

尽管我知道这一切,但您可能会感到惊讶,因为我经常忘记执行其中一个步骤并最终针对错误版本的事物进行测试,无论是完全安装的旧版本(忘记 -Mblib) 或旧的开发源(忘记 make).这导致我调试语句,例如:

Despite the fact that I know all this, you might be surprised that I often forget to do one of those steps and end up testing against the wrong version of things, whether the fully installed old version (forgot -Mblib) or the old development sources (forgot make). This leads me to debugging statements such as:

print "No really, this is the Foo version. kthnxbye\n";

这篇关于如何在 Perl 发行版中仅运行特定测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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