如何告诉 phpunit 在失败时停止

How to tell phpunit to stop on failure

我是 运行 一大套 phpunit 测试,我希望在失败时立即查看哪个测试失败,而不是等待所有测试完成然后将其列出所有的失败。

我如何告诉 phpunit 这样做?

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

您也可以在 CLI 中使用它:phpunit --stop-on-failure

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

  • stopOnError - "Stop execution upon first error."
  • 失败时停止 - "Stop execution upon first error or failure."
  • stopOnIncomplete - "Stop execution upon first incomplete test."

更多信息位于:PHPunit manual