0

如果 setUpBeforeClass() 抛出异常,PHPUnit 的 JUnit XML 输出中不会报告失败或错误。为什么?

示例测试类:

<?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');
  }
}

命令行:

phpunit --verbose --log-junit out.xml Test.php

控制台输出:

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 输出:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="Test" file="/tmp/phpunit-broken/Test.php"/>
</testsuites>

更多信息:

$ 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

可能相关:

4

0 回答 0