Attempting to run PHPUnit using an XML configuration file throws an exception

I have been trying (quite a while, using the chat guys in PHP) to successfully integrate PHPUnit with PhpStorm.

I installed the phpunit.xml file as follows:

 <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals = "false" backupStaticAttributes = "false" colors = "true" convertErrorsToExceptions = "true" convertNoticesToExceptions = "true" convertWarningsToExceptions = "true" processIsolation = "false" stopOnFailure = "false" syntaxCheck = "false" bootstrap = "bootstrap.php" > <testsuites> <testsuite name="Lamed Test Suite"> <directory>Custom/*</directory> </testsuite> </testsuites> </phpunit> 

And successfully configured PHP storm to read from this file.

The problem is that when I run the tests, I get the following error in the PhpStorm console:

 D:\Websites\php\php.exe C:\fakepath\ide-phpunit.php --bootstrap D:\Websites\htdocs\lamed\tests\boostrap.php --configuration D:\Websites\htdocs\lamed\tests\phpunit.xml Testing started at 23:51 ... Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "Lamed Test Suite.php" nor "Lamed Test Suite.php" could be opened.' in D:\Websites\php\pear\PHPUnit\Util\Skeleton\Test.php:100 Stack trace: #0 D:\Websites\php\pear\PHPUnit\TextUI\Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('Lamed Test Suit...', '') #1 C:\Users\Dor\AppData\Local\Temp\ide-phpunit.php(95): PHPUnit_TextUI_Command->run(Array, true) #2 C:\Users\Dor\AppData\Local\Temp\ide-phpunit.php(434): IDE_PHPUnit_TextUI_Command::main() #3 {main} thrown in D:\Websites\php\pear\PHPUnit\Util\Skeleton\Test.php on line 100 Process finished with exit code 255 

Obviously, this can be seen from the name= attribute of the testsuite element. The question is why?

UPDATES

  • I am running Windows Seven x64 SP1 and PHPStorm 4.0.3 . PHPUnit version 3.6.12 .
  • Entering phpunit -c "D:\Websites\htdocs\lamed\tests\phpunit.xml" in the CLI actually gives the same results.
  • My Custom directory is in the same folder as the phpunit.xml file.

I am puzzled. Thank any help.

+8
phpstorm phpunit integration
Aug 07 2018-12-12T00:
source share
3 answers

Drop /* from the <directory> element. This textual content of the element should point to a directory - not a glob file.

 <directory>Custom</directory> 

For more information on specifying individual files and inclusion patterns, see the PHPUnit configuration documentation .

By default, all files ending with Test.php (for example, UserTest.php ) will be checked for test cases. If you have a different naming convention, you can either switch or add the suffix attribute. For example, if you name your tests like User.test.php , use this:

 <directory suffix=".test.php">Custom</directory> 
+10
Aug 08 2018-12-12T00:
source share

What you experience is a rollback. It looks like your testuite is empty (and there is no other additional non-empty testuite).

In this case, PHPUnit will also try to just open something suitable that won't work. Then you will see an error message.

  • If you have only one empty testuite, you will see an exception called testuite and php to try it.

     Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "Empty-Testuite.php" nor "Empty-Testuite.php" could be opened.' 
  • If you have several empty testuite and no working tests, you will see only an error in php, but no name has been added.

     Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither ".php" nor ".php" could be opened.' 
  • If you have at least a working testuite, but one or more empty tests, you will see a short report for each empty testuite, but without errors:

     Empty test suite. 

When I write that this is a reserve, this should not mean that this behavior is intended by PHPUnit. It is normal to see an error in your case, because before starting the tests you need at least one run. And before you start by setting up testuites, the same thing.

Fix the main problem that is not in the test, and the error has disappeared.

The wildcard * , as mentioned in another answer - even I'm sure it’s right not to have one - does not play any role with your problem as far as I could see.




The information in this answer is based on

  • PHPUnit 3.6.7 by Sebastian Bergman.
  • PHP 5.4.5 by php.net
+1
Aug 08 2018-12-12T00:
source share

If the same problem changed the value of the directory to an absolute path instead of a relative path, and it worked. For example, I changed the tests in C: \ eclipse \ Workspace \ testweb

Too bad, I had to go through a lot of information, and this is not mentioned in the documentation, nor documented how to start the command line interface using the xml configuration file.

phpunit -c tests / all.xml

Php test files should end with a test, as well as myTest.php, even if you add the elements of the file C: \ eclipse \ Workspace \ testweb \ Tests \ Classes \ something.php will not work, but C: \ eclipse \ Workspace \ testweb \ Tests \ Classes \ somethingtest.php will work

+1
02 Sep
source share



All Articles