如何告诉 phpunit 在失败时停止

问题描述 投票:0回答:1

我正在运行一大套 phpunit 测试,我想在哪个测试失败后立即查看它失败了,而不是等待所有测试完成然后让它列出所有失败。

我如何告诉 phpunit 这样做?

php unit-testing phpunit
1个回答
265
投票

stopOnFailure="true"
属性添加到您的
phpunit.xml
根元素。

您也可以在 CLI 中使用它:

phpunit --stop-on-failure

来自手册和其他一些可能对您有用的信息:

  • stopOnError - “出现第一个错误时停止执行。”
  • stopOnFailure - “在第一次错误或失败时停止执行。”
  • stopOnIncomplete - “在第一个不完整的测试时停止执行。”

更多信息请访问:PHPunit 手册

© www.soinside.com 2019 - 2024. All rights reserved.