Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

PHPUnit does not report errors in XML configuration files #127

nconstant opened this Issue Jan 19, 2011 · 16 comments


None yet
4 participants

Here is the output from a command prompt window:

C:\nate>phpunit --version
PHPUnit 3.5.9 by Sebastian Bergmann.

 Volume in drive C is OS
 Volume Serial Number is 34DD-4D8B

 Directory of C:\nate

01/19/2011  01:48 PM    <DIR>          .
01/19/2011  01:48 PM    <DIR>          ..
01/19/2011  01:00 PM               142 build-number.txt
01/19/2011  10:27 AM             2,435 build.xml
01/19/2011  01:39 PM    <DIR>          htdocs
01/19/2011  01:41 PM    <DIR>          includes
01/19/2011  01:47 PM                 0 out.txt
01/19/2011  11:58 AM             2,064 phpunit.xml
01/19/2011  01:41 PM    <DIR>          test
01/19/2011  01:41 PM    <DIR>          test-reports
01/19/2011  01:41 PM    <DIR>          test2
               4 File(s)          4,641 bytes
               7 Dir(s)  13,535,272,960 bytes free

C:\nate>phpunit --configuration phpunit.xml

The return code is "255", if that helps.

Can you post the contents of phpunit.xml?

This is the phpunit.xml file contents.


  <testsuite name="All New MyCricket2 Tests">

also, I do not get this error when running on my local machine (win 7), this error is coming from a Win 2003 server.

Here is the successful output on Win 7

C:\Zend_Projects\MyCricket2_TEST_SVN>phpunit --version
PHPUnit 3.5.9 by Sebastian Bergmann.

C:\Zend_Projects\MyCricket2_TEST_SVN>phpunit --configuration phpunit.xml
PHPUnit 3.5.9 by Sebastian Bergmann.


Time: 1 second, Memory: 8.00Mb

There was 1 failure:

  1. PgetProductDetailByProductListTest::procedureIsBehavingItself
    Procedure call returned no rows


Tests: 21, Assertions: 53, Failures: 1, Skipped: 1.



whatthejeff commented Jan 21, 2011

Looks like your phpunit.xml file is missing the closing </phpunit> tag. Check your error log and see if you find something like:

[20-Jan-2011 22:15:20] PHP Fatal error:  Uncaught exception 'PHPUnit_Framework_Exception' with message 'Could not load "C:\Program Files\PHP\phpunit.xml".' in C:\Program Files\PHP\PEAR\PHPUnit\Util\XML.php:212

Once I added the closing tag, I was able to get everything to work as expected:

Windows Server 2003
C:\Program Files\PHP>systeminfo | findstr /C:"OS Name"
OS Name: Microsoft(R) Windows(R) Server 2003, Standard Edition

C:\Program Files\PHP>type phpunit.xml

<phpunit backupGlobals="false"



  <testsuite name="All New MyCricket2 Tests">

Running the test
C:\Program Files\PHP>phpunit --configuration phpunit.xml
PHPUnit 3.5.10 by Sebastian Bergmann.


Time: 0 seconds, Memory: 3.00Mb

OK (1 test, 1 assertion)

C:\Program Files\PHP>

whatthejeff commented Jan 21, 2011

Closed by 83f8fec.

  • An error message is now printed for errors while parsing the phpunit.xml file.
  • Fixed a bug where XML errors were not being collected correctly.

It looks like I had a copy/paste error into this ticket. My phpunit.xml file does have the closing tag in it. I just did a pear upgrade phpunit/PHPUnit to 3.5.10 and i still get the same error/issue. The script is just dying without running any tests. the return code is still 255.

(it looks like I dont know how to paste the xml contents into this box)

Please do note that PHPUnit 3.5.10 does not have the fix for the "PHPUnit does not report errors in XML configuration files" issue.

I don't think the error is due to an error in the XML configuration file. I get the same issue if i try to run "phpunit AllTests.php" directly without using a configuration file. (note, i did have the closing phpunit tag so i dont think that was the issue).

Thanks for your help.


whatthejeff commented Jan 21, 2011

Have you checked your error logs? What you're describing sounds symptomatic of a fatal error.

cebe pushed a commit to cebe/phpunit that referenced this issue Aug 15, 2011

Fixes #127.
 * An error message is now printed for errors while parsing the phpunit.xml file.
 * Fixed a bug where XML errors were not being collected correctly.

This issue is still prevalent, even upgrading to latest version, PHPUnit 4.8.6, I often end up with test scripts only running so far before exiting with code 255.

I have found this may be due to class not found, or method not found, or method parameters missing or all number of things which are potentially either notices or fatal errors.

The question is why do you exit with code 255 leaving developers completely in the dark rather than reporting the cause of the error?

What do "class not found", "method not found", etc. have to do with the XML configuration file?

I'm referring to the issue of phpunit throwing exit code 255 with no other information whenever it hits something unexpected - perhaps this should be another issue.

FYI just noticed the problem, looks like I was trying to access a protected method. So why does phpunit not output 'PHP Fatal error: Cannot access protected method'?

PHPUnit does not output errors like that, PHP does. PHPUnit does not prevent such errors from being printed, custom error handlers do that.

As far as I am aware I do not have any custom error handlers, and not only does it not print the PHP errors, phpunit also dies at that test and ceases to continue.

However I think I have found the cause in my bootstrap I had the line:
error_reporting(E_ALL & E_STRICT & ~E_DEPRECATED);

as oppose to
error_reporting(E_ALL & ~E_DEPRECATED);


This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment