如何使用phpunit --testsuite选项?

时间:2016-08-12 18:00:10

标签: php phpunit

如何使用phpunit --testsuite命令?

例如,我有一个测试文件:

test/xxx/RegistrationConfirmedListenerTest.php

如果我运行phpunit,那么它将在RegistrationConfirmedListenerTest.php中运行测试,但它也会在我的tests文件夹中运行所有其他测试。

我尝试过使用这样的--testsuite选项:

phpunit --testsuite RegistrationConfirmedListenerTest

然而,没有任何东西可以运行。

PHPUnit 4.8.26 by Sebastian Bergmann and contributors.



Time: 46 ms, Memory: 4.00Mb

No tests executed!

我在这里阅读了文档,但没有任何示例可以提供帮助:

https://phpunit.de/manual/current/en/textui.html

1 个答案:

答案 0 :(得分:3)

您必须创建一个phpunit.xml并在那里定义您的测试套件。

<testsuites>
    <testsuite name="youttestsuitename1">
        <file>./path/to/folder/</file>
    </testsuite>
    <testsuite name="youttestsuitename1">
        <file>./path/to/folder2/</file>
    </testsuite>
</testsuites> 

official documentations的更多信息