如何使用phpunit运行单一测试方法? [英] How to run single test method with phpunit?

查看:109
本文介绍了如何使用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屋!

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