Is it possible in Laravel to run unit test based on the folder they're placed in?
Currently, the phpunit.xml specifies /tests as the root directory for unit testing:
...
<testsuites>
<testsuite name="Application Test Suite">
<directory>./app/tests/</directory>
</testsuite>
</testsuites>
...
Test are ran via CLI with phpunit
command. I would like to organize tests into subfolders, like this:
/tests
so I can run tests only from the specified subfolder like: phpunit integration
.
I tried the above, however the framework assumes that "integration" is the name of a PHP file that doesn't exist.
How do I achieve my goal?
This actually has nothing to do with Laravel. It's just PHPUnit.
You can define testsuites
and execute them by name.
<testsuites>
<testsuite name="unit">
<directory>./app/tests/unit/</directory>
</testsuite>
<testsuite name="integration">
<directory>./app/tests/integration/</directory>
</testsuite>
</testsuites>
Then run phpunit --testsuite integration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With