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!

3
  • What is the phpunit version? And what is your php version? Commented Sep 30, 2019 at 10:22
  • Hello and welcome to Stack Overflow, it's highly recommended you upgrade your PHPUnit version and install packages via Composer instead of Pear Commented Sep 30, 2019 at 10:27
  • Looks like it's a PHP 7.3 change. stackoverflow.com/questions/54184707/… Commented Nov 15, 2019 at 18:46

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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

Comments

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 :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.