If setUpBeforeClass() fails, test failures are hidden in PHPUnit's JUnit XML output
- by Adam Monsen
If setUpBeforeClass() throws an exception, no failures or errors are reported in the PHPUnit's JUnit XML output. Why?
Example test class:
<?php
class Test extends PHPUnit_Framework_TestCase
{
public static function setUpBeforeClass() {
throw new \Exception('masks all failures in xml output');
}
public function testFoo() {
$this->fail('failing');
}
}
Command line:
phpunit --verbose --log-junit out.xml Test.php
Console output:
PHPUnit 3.6.10 by Sebastian Bergmann.
E
Time: 0 seconds, Memory: 3.25Mb
There was 1 error:
1) Test
Exception: masks all failures in xml output
/tmp/pu/Test.php:6
FAILURES!
Tests: 0, Assertions: 0, Errors: 1.
JUnit XML output:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="Test" file="/tmp/phpunit-broken/Test.php"/>
</testsuites>
More info:
$ php --version
PHP 5.3.10-1ubuntu3.1 with Suhosin-Patch (cli) (built: May 4 2012 02:21:57)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans