繁体   English   中英

由于语法错误或致命错误,如何在PHPunit中导出失败的测试?

[英]How do I export failed tests in PHPunit due to syntax errors or Fatal errors?

以下是我的phpunit.xml文件。 一旦发生PHP致命错误,所有日志记录方法都会停止。 我希望能够有此错误的日志。

<phpunit verbose="true" colors="true" stopOnFailure="false" syntaxCheck="true">
    <logging>
    <log type="tap" target="results/results.tap"/>
    <log type="testdox-text" target="results/results.txt" />
        <log type="junit" target="results/results.junit" logIncompleteSkipped="true"/>
        <log type="json" target="results/results.js"/>
        <log type="coverage-html" target="results/report" charset="UTF-8"
           yui="false" highlight="false"
           lowUpperBound="35" highLowerBound="70"/>
    </logging>
</phpunit>

由于phpunit(或更确切地说是您的测试)在致命错误中运行,因此php解释器无法执行的工作远不止于此,因此通过phpunit进行日志记录似乎相当困难。

也许将每个测试作为单独的进程运行(使用--process-isolation开关或设置processIsolation =“ true”)可能会对您有所帮助。 但这会使您的Testsuite变慢,等等。

因此,作为一种快速的解决方案,您可以将php的错误输出放入日志文件中(以防display_errors打开)。

phpunit yourTests 2> errors.log

也许为您的测试运行使用不同的php.ini并在那里提供日志文件,或者通过以下方式将其传递给php

echo "" > error.log && phpunit -d error_log=error.log yourTests

因此,您至少要有一个要检查错误的文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM