1
votes

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!

2
What is the phpunit version? And what is your php version?Koala Yeung
Hello and welcome to Stack Overflow, it's highly recommended you upgrade your PHPUnit version and install packages via Composer instead of PearSalim Djerbouh
Looks like it's a PHP 7.3 change. stackoverflow.com/questions/54184707/…ceejayoz

2 Answers

2
votes

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
1
votes

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.