1
votes

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?

1

1 Answers

2
votes

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