I have a Laravel project setup in PhpStorm. Using PHP 7.3 with PHPUnit 8.4.0.
I have phpunit.xml setup as below, and when I do Run -> Run -> phpunit.xml it works fine and all the tests in /tests/feature/ get run...yay.
The output is something like this when it starts:
[vagrant:///home/mypc/code/homestead]:/usr/bin/php /home/vagrant/myproject/vendor/phpunit/phpunit/phpunit --configuration /home/vagrant/myproject/phpunit.xml --teamcity --cache-result-file=/home/vagrant/myproject/.phpunit.result.cache
However I now have lots of tests and I don't always want to run all the tests every time, so I should be able to just right click on any of the test methods and click "Run ...method name...", but when I do an error occurs:
[vagrant:///home/mypc/code/homestead]:/usr/bin/php /home/vagrant/myproject/vendor/phpunit/phpunit/phpunit --configuration /home/vagrant/myproject/phpunit.xml --filter "/(::test_example_test_for_running)( .*)?$/" Tests\\Feature\\ExampleTest\\ExampleTest /home/vagrant/myproject/tests/Feature/ExampleTest.php --teamcity --cache-result-file=/home/vagrant/myproject/.phpunit.result.cache
Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'Tests\\Feature\\ExampleTest\\ExampleTest' could not be found in '/home/vagrant/myproject/tests/Feature/ExampleTest.php'. in /home/vagrant/myproject/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php:65
Here is my phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<extensions>
<extension class="Tests\Bootstrap"/>
</extensions>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="APP_CONFIG_CACHE" value="bootstrap/cache/config.phpunit.php"/>
<server name="APP_SERVICES_CACHE" value="bootstrap/cache/services.phpunit.php"/>
<server name="APP_PACKAGES_CACHE" value="bootstrap/cache/packages.phpunit.php"/>
<server name="APP_ROUTES_CACHE" value="bootstrap/cache/routes.phpunit.php"/>
<server name="APP_EVENTS_CACHE" value="bootstrap/cache/events.phpunit.php"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>