如何使用phpunit运行单一测试方法? [英] How to run single test method with phpunit?
问题描述
我正在努力使用phpunit
在文件escalation/EscalationGroupTest.php
中运行一个名为testSaveAndDrop
的测试方法.我尝试了以下组合:
I am struggling to run a single test method named testSaveAndDrop
in the file escalation/EscalationGroupTest.php
with phpunit
. I tried the following combinations:
phpunit EscalationGroupTest escalation/EscalationGroupTest.php --filter=escalation/EscalationGroupTest.php::testSaveAndDrop
phpunit EscalationGroupTest escalation/EscalationGroupTest.php --filter=EscalationGroupTest.php::testSaveAndDrop
phpunit EscalationGroupTest escalation/EscalationGroupTest.php --filter=EscalationGroupTest::testSaveAndDrop
phpunit EscalationGroupTest escalation/EscalationGroupTest.php --filter=testSaveAndDrop
在每种情况下,都执行文件escalation/EscalationGroupTest.php
中的所有测试方法.如何只选择一种方法呢?
In each case all test methode in the file escalation/EscalationGroupTest.php
are executed. How to select just ONE method instead?
该类的名称为EscalationGroupTest
,而phpunit
的版本为3.2.8.
The name of the class is EscalationGroupTest
and the version of phpunit
is 3.2.8.
推荐答案
以下命令在单个方法上运行测试:
The following command runs the test on a single method:
phpunit --filter testSaveAndDrop EscalationGroupTest escalation/EscalationGroupTest.php
phpunit --filter methodName ClassName path/to/file.php
对于较新版本的phpunit,它只是:
For newer versions of phpunit, it is just:
phpunit --filter methodName path/to/file.php
这篇关于如何使用phpunit运行单一测试方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!