Laravel: organizing tests into folders and running them

Is it possible in Laravel to run unit test based on the folder in which they are placed?

Currently phpunit.xml is specifying / tests as the root directory for unit testing:

...
<testsuites>
    <testsuite name="Application Test Suite">
        <directory>./app/tests/</directory>
    </testsuite>
</testsuites>
...

The test is performed through the CLI using the command phpunit. I would like to organize tests in subfolders, for example:

/ tests

  • /block
  • /integration

so I can run tests only from specified subfolders, for example phpunit integration.

I tried above, but within the framework of the platform it is assumed that "integration" is the name of a PHP file that does not exist.

How can I achieve my goal?

+4
1

Laravel. PHPUnit.

testsuites .

<testsuites>
    <testsuite name="unit">
        <directory>./app/tests/unit/</directory>
    </testsuite>
    <testsuite name="integration">
        <directory>./app/tests/integration/</directory>
    </testsuite>
</testsuites>

phpunit --testsuite integration

+17

Source: https://habr.com/ru/post/1569212/


All Articles