PHPUnit throws error but works when specifying the specific test
I recently upgraded our codebase to use Laravel 5.6 and I'm finding a weird issue where phpunit will fail with the following error message:
PHP Fatal error: Cannot declare class Tests\Feature\CreateVisitorTest, because the name is already in use in /var/www/grow/tests/Feature/CreateVisitorTest.php on line 12
However if I were to specify the file specifically it works fine.
e.g., this command works and my test passes: phpunit tests/feature/CreateVisitorTest.php
You probably have the same test class name defined in another test file somewhere. This happens to me occasionally if I copy the boilerplate of a test class to a new file and forget to change the class name.
Agreed with Talinon, the error is so obvious and the system won't lie. You should double check that very carefully. I suspect that you may defining the test function name as the same test class name.