Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wonder95's avatar

php artisan test will not run in Laravel 12 with PHPUnit 11.5

I am upgrading a large Laravel app from 11 to 12, and in the process updated phpunit from 10.5 to 11. Until now, we have run tests locally and on CircleCI with this command

php artisan test --log-junit ~/phpunit-out/openai_tests/junit.xml --testsuite="MySuite"

However, with this update, both locally and on CircleCI, that command does not run. All it does is return the help screen:

php artisan test --log-junit ~/phpunit-out/openai_tests/junit.xml --testsuite="MySuite"
Laravel Framework 12.2.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
      --silent          Do not output any message
  -q, --quiet           Only errors are displayed. All other output is suppressed
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands for the "test" namespace:
  test:files-by-relevancy-to-products-and-services  Scratch command
  test:function-call           

Testing further, just running

php artisan test

does the same thing; nothing. If I run phpunit directly:

vendor/bin/phpunit --log-junit ~/phpunit-out/unit_tests/junit.xml --testsuite="MySuite"

they run as expected.

None of my configs have changed (e.g. phpunit.xml) or directory locations. I have been searching and asking my AI friends, and I can find no direct answers.

Any thoughts on why php artisan test won't run at all?

0 likes
5 replies
LaryAI's avatar
Level 58

The issue you're experiencing with php artisan test not running in Laravel 12 with PHPUnit 11.5 could be due to a few reasons. Here are some steps to troubleshoot and potentially resolve the problem:

  1. Check Laravel Version Compatibility: Ensure that Laravel 12 is compatible with PHPUnit 11.5. Sometimes, specific versions of Laravel may have compatibility issues with certain PHPUnit versions. Check the Laravel documentation or release notes for any known issues.

  2. Update Composer Dependencies: Make sure all your dependencies are up to date. Run the following command to update your dependencies:

    composer update
    
  3. Verify PHPUnit Configuration: Double-check your phpunit.xml configuration file to ensure there are no deprecated or incompatible settings with PHPUnit 11.5. Look for any changes in PHPUnit's configuration requirements between versions 10.5 and 11.5.

  4. Check Laravel's Test Command: Laravel's artisan test command is a wrapper around PHPUnit. Ensure that the TestCommand class in Laravel is not overridden or modified in a way that could cause issues. You can check this by looking at the Illuminate\Foundation\Console\TestCommand class.

  5. Clear Cache: Sometimes, cached configurations can cause issues. Clear the cache using:

    php artisan config:clear
    php artisan cache:clear
    php artisan clear-compiled
    
  6. Check for Custom Commands: The output you provided shows custom commands under the "test" namespace. Ensure that there are no custom commands or service providers that might be interfering with the default test command.

  7. Debugging: If the above steps do not resolve the issue, you can try debugging by adding some logging or dd() statements in the TestCommand class to see if the command is being executed and where it might be failing.

  8. Reinstall Laravel Installer: If you are using the Laravel installer, ensure it is up to date:

    composer global update laravel/installer
    

If none of these steps resolve the issue, consider creating a fresh Laravel 12 project and testing if php artisan test works there. This can help determine if the issue is specific to your project setup or a broader compatibility issue.

ThawHtooZin's avatar
Level 4

It turns out that Laravel 12 has completely removed php artisan test, which is why the command no longer works. Instead of running tests through Artisan, Laravel now expects you to use PHPUnit directly.

Solution:

Replace your old command:

php artisan test --log-junit ~/phpunit-out/openai_tests/junit.xml --testsuite="MySuite"

with this:

vendor/bin/phpunit --log-junit ~/phpunit-out/openai_tests/junit.xml --testsuite="MySuite"

This runs PHPUnit directly and works as expected.

If you still want to use artisan test, you can try reinstalling nunomaduro/collision:

composer require nunomaduro/collision --dev

However, Laravel officially recommends running PHPUnit directly from now on.

Hope this helps!

wonder95's avatar

@ThawHtooZin Thanks much!

Out of curiosity, where did you see this? I looked in upgrade notes and other searching, but didn't see this somehow.

wonder95's avatar

@ThawHtooZin Thanks much!

Out of curiosity, where did you see this? I looked in upgrade notes and other searching, but didn't see this somehow.

wonder95's avatar

Ah, I see, it doesn't specifically say in the docs that it was removed in 12, it just says to call it directly.

Please or to participate in this conversation.