Ginger Ginger - 3 months ago 8
PHP Question

How to use phpunit --testsuite option?

How do I use the phpunit --testsuite command?

For example, I have a testfile:

test/xxx/RegistrationConfirmedListenerTest.php


If I run phpunit, then it will run the tests in RegistrationConfirmedListenerTest.php, but it also runs all other tests in my tests folder.

I have tried using this the --testsuite option like this:

phpunit --testsuite RegistrationConfirmedListenerTest


However, nothing runs.

PHPUnit 4.8.26 by Sebastian Bergmann and contributors.



Time: 46 ms, Memory: 4.00Mb

No tests executed!


I have read the docs here but there aren't any examples to help:

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

Answer

You have to create a phpunit.xml and define your testsuites there.

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

More info to official documentations