2

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!

Pradeep
  • 9,667
  • 13
  • 27
  • 34
Mohanraj
  • 21
  • 1
  • 2
  • What is the phpunit version? And what is your php version? – Koala Yeung Sep 30 '19 at 10:22
  • Hello and welcome to Stack Overflow, it's highly recommended you upgrade your PHPUnit version and install packages via [Composer](http://getcomposer.org) instead of Pear – Salim Djerbouh Sep 30 '19 at 10:27
  • Looks like it's a PHP 7.3 change. https://stackoverflow.com/questions/54184707/warning-continue-targeting-switch-is-equivalent-to-break-did-you-mean-to-u – ceejayoz Nov 15 '19 at 18:46

3 Answers3

4

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.

Naltroc
  • 989
  • 1
  • 14
  • 34
  • I am searching from two day but could not solve the problem, if I try to upgrade phpunit it say "mpdf/mpdf v7.1.5 requires php ^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0 -> your P HP version (7.3.22) does not satisfy that requirement." But your solution save me now I can run my test by using backslashes instead of forward slashes. Thanks man – Shoaib Rehan Sep 23 '20 at 18:26
3

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
Edrich
  • 175
  • 1
  • 8
0

Laravel uses

php artisan test .\tests\Feature\ExampleTest.php

for testing, not phpunit. https://laravel.com/docs/10.x/testing. I just ran into the same, tried to use old ways on a new tool :)

Dgloria
  • 161
  • 1
  • 12