本文介绍了PHPUnit问题-没有错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力解决这个问题.

I've been trying to solve this problem for quite some time.

我有一个简单的PHPUnit测试用例,其中包含2个测试.运行它时,我得到以下输出:

I have a simple PHPUnit test case with 2 tests. When I run it, I get this output:

PHPUnit 3.5.14 by Sebastian Bergmann.

.

因此第一个断言运行并通过.但是,第二个断言会导致一些PHP错误(异常或其他错误),并且PHPUnit会死掉而没有任何有关可能出错的信息.

So the first assertion runs, passes. The second assertion, however, causes some PHP error (exception or something), and PHPUnit just dies without any info about what could have gone wrong.

这是我的phpunit.xml:

Here is my phpunit.xml:

<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
    backupStaticAttributes="false"
    colors="false"
    convertErrorsToExceptions="true"
    convertNoticesToExceptions="true"
    convertWarningsToExceptions="true"
    processIsolation="false"
    stopOnFailure="true"
    syntaxCheck="false"
    bootstrap="bootstrap.php.cache"
>
    <testsuites>
        <testsuite name="Portal Test Suite">
            <directory>../src/OneSolution/Portal/*Bundle/Tests</directory>
        </testsuite>
    </testsuites>
</phpunit>

syntaxCheck设置为true不会提供有关该错误的任何其他信息.但是,它会打印两次(在运行任何测试之前)The filename, directory name, or volume label syntax is incorrect.

Setting syntaxCheck to true doesn't give any additional information about the error. However, it does print twice (before running any tests) that The filename, directory name, or volume label syntax is incorrect.

???

那么,有没有人知道如何使PHPUnit报告这些错误消息(--verbose选项也无济于事)?

So, does anyone have any ideas what could I do to make PHPUnit report those error messages (the --verbose option didn't help either)?

编辑:我发现了导致测试失败的原因.方法名称有误(我猜我太依赖代码辅助了).但是,这不能解决主要问题. PHPUnit不会报告任何警告,错误或异常.

I've found out what has been causing the test to fail. There was a mistyped method name (I rely too much on code assist, I guess). However, this doesn't solve the main problem. Any warnings, errors or exception go unreported by PHPUnit.

推荐答案

好,因此,如果任何人都无法从PHPUnit命令行获取任何内容或输出不完整,请仔细检查您的php.ini配置指令:

OK, so if anyone has trouble with getting none or incomplete output from PHPUnit command line, double-check your php.ini configuration directives:

  • error_reporting-对于您的开发环境,应设置为E_ALL | E_STRICT
  • display_errors-应设置为On
  • error_reporting - should be set to E_ALL | E_STRICT for your development environment
  • display_errors - should be set to On

这篇关于PHPUnit问题-没有错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:20
查看更多