在 JUnit5 中测试失败后如何 运行 编码?

How to run code after test failure in JUnit5?

如何在 JUnit 5 中测试失败后 运行 函数或总结代码?

这可以使用 TestWatcher in JUnit 5. On JUnit 4 however, you can use ErrorCollector 来完成。

This answer出色地为您的问题提供了解决方案。