1

I am currently getting this message when I attempt to run a test in PhpStorm:

C:\xampp\php\php.exe C:\xampp\htdocs\phpunit-test\tests\EmailTest.php

PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found in C:\xampp\htdocs\phpunit-test\tests\EmailTest.php on line 10

Fatal error: Class 'PHPUnit\Framework\TestCase' not found in C:\xampp\htdocs\phpunit-test\tests\EmailTest.php on line 10

Process finished with exit code 255

I am currently working with the following:

  • XAMPP for Windows 5.6.24
  • PhpStorm 2017.2.1
  • PHPUnit-5.7.21.phar

The file and test I am running are exactly what is found on the PHPUnit website

I haven't made any special or particular changes to PhpStorm, so I do not understand what may be causing the default PHPUnit test to fail. Maybe I am missing something:

My code (you can ignore the phpunit-6.3.0.phar file as it is in no way being used -- I was just trying to see if it made a difference or not what version of PHPUnit I was using)

EDIT: 8/23/2017

So I tried @Florian suggestion, and created a phpunit.xml AND a phpunit.xml.dist file, using the code found on [phpunit's website for version 5.7] and I now get this error:

xml or xmldist fail

I do not understand why, when I either use the phpunit.xml or phpunit.xml.dist file, I get these errors. Am I getting closer to resolving this or is there something else?

Alex W.
  • 11
  • 4
  • 2
    Possible duplicate of [Why, Fatal error: Class 'PHPUnit\_Framework\_TestCase' not found in ...?](https://stackoverflow.com/questions/6065730/why-fatal-error-class-phpunit-framework-testcase-not-found-in) – Abdulla Nilam Aug 22 '17 at 20:12
  • 2
    Read this as well https://www.jetbrains.com/help/phpstorm/testing-with-phpunit.html – Abdulla Nilam Aug 22 '17 at 20:12
  • 1
    https://confluence.jetbrains.com/display/PhpStorm/Testing+PHP+Applications – LazyOne Aug 22 '17 at 20:56

1 Answers1

2

You must set either the "Default configuration file" or the "Default bootstrap file" with a path to the config file.

The "Default configuration file" should be set to a phpunit.xml.dist file, more information about the file can be found under the section Organizing Tests

or the other option is to give an autoload.php file to set some configurations. In the PHPunit Getting started guide it is listed in the Test Execution.

More information about Autoloading from php.net

Florian
  • 845
  • 1
  • 9
  • 17
  • Hi Florian, I tried your solution but I ran into another issue. Please see the edit to my original post for the result. – Alex W. Aug 23 '17 at 20:58
  • Hi Alex, please make sure you have all tags inside the file. The error says that you're missing the closing phpunit tag – Florian Aug 24 '17 at 06:36