dongsu0308 2012-06-06 22:36
浏览 66

如果setUpBeforeClass()失败,则测试失败隐藏在PHPUnit的JUnit XML输出中

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

Possibly related:

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 linux驱动,linux应用,多线程
    • ¥20 我要一个分身加定位两个功能的安卓app
    • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
    • ¥15 IAR程序莫名变量多重定义
    • ¥15 (标签-UDP|关键词-client)
    • ¥15 关于库卡officelite无法与虚拟机通讯的问题
    • ¥15 目标检测项目无法读取视频
    • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
    • ¥100 求采集电商背景音乐的方法
    • ¥15 数学建模竞赛求指导帮助