微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

让PHPUnit忽略了什么?

我有一个 PHPUnit Test类,我想在测试运行中忽略它.我知道我可以通过重命名它来使它在文件名中不包含单词Test,但我宁愿不这样做,因为它比我想要的更多地混淆了源代码控制水域.

有没有人有建议?

PHPunit命令有几个选项可以帮助定义应该和不应该运行哪些测试:
$PHPunit --help
PHPUnit 3.4.0beta5 by Sebastian Bergmann.

Usage: PHPunit [switches] UnitTest [UnitTest.PHP]
       PHPunit [switches] <directory>
...
  --filter <pattern>       Filter which tests to run.
  --group ...              Only runs tests from the specified group(s).
  --exclude-group ...      Exclude tests from the specified group(s).
  --list-groups            List available test groups.
...

那些可能不会准确指出你想要的……但他们可能会有所帮助.

有关更多详细信息,请参阅The Command-Line Test Runner

特别是,我有点像组功能:只需在测试的PHPdoc中使用@group标签,重新组合它们(例如,每个“功能块”一组);然后,您可以在命令行上使用–group或–exclude-group选项来指定应该或不应该运行哪些测试.

在您的情况下,如果您无法修改测试,也许–filter选项可以提供帮助,具体取决于您的测试被命名的方式(即,是否有办法识别您想要运行的测试):

--filter

Only runs tests whose name matches the given pattern. The pattern can be
either the name of a single test or a
regular expression that matches
multiple test names.

另一种解决方案,如果您并不总是更改要运行的测试的“组”,可能是使用仅包含您要运行的测试的测试套件.

例如,看看Composing a Test Suite Using XML Configuration.

原文地址:https://www.jb51.cc/php/133809.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐