Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpunit is not running in laravel

Tags:

php

laravel

lumen

I tried to run phpunit with sample test but it was not executing. It shows NO TEST EXECUTED.

My default File contains ExampleTest.php and TestCase.php

C:\xampp\htdocs\amber_fuel>phpunit PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 277

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 277 PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 285

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 285 PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from C:\xampp\htdocs\amber_fuel\phpunit.xml

Time: 90 ms, Memory: 8.00MB

No tests executed!

like image 937
Mohanraj Avatar asked Dec 06 '25 08:12

Mohanraj


2 Answers

It looks like you are running the global instance of PHPUnit on a Windows machine. I had the same problem, and the solution was extremely simple:

  1. Use the local version of PHPUnit managed by Composer (which should be much newer than the global environment version of 3.7.21).
  2. Use backslashes insteadof forward slashes when calling your test runner.

If I am in the root directory of my project for example, I would run vendor\bin\phpunit

Your tests should then run and print the results.

like image 107
Naltroc Avatar answered Dec 08 '25 22:12

Naltroc


I assume you're running it this way?

./vendor/bin/phpunit

Either enclose it in quotes like so:

"./vendor/bin/phpunit"

Or run it using powershell, by simply typing powershell from cmd then run it the regular way:

./vendor/bin/phpunit
like image 20
Edrich Avatar answered Dec 08 '25 20:12

Edrich