JUnit 5:是否可以在 Maven Surefire 插件中设置 TestExecutionListener?

JUnit 5: Is it possible to set a TestExecutionListener in Maven Surefire Plugin?

我想使用 JUnit 5 和 TestExecutionListener 接口在测试 运行 完成后进行一些清理。整个项目使用 JUnit Jupiter,不涉及 Vintage。

在 Maven Surefire 中,它能够通过配置设置 JUnit 4 RunListener 来存档它。 Surefire 是否能够识别新的 JUnit 5 TestExecutionListener?如果没有,有没有办法进行 JUnit 5 测试并使用 TestExecutionListenerRunListener?

我不想创建自己的 Launcher 只是为了使用侦听器执行测试。

Maven Surefire 目前不支持通过其配置添加 TestExecutionListener。我认为您应该为他们提出一个问题,因为他们目前正在将 JUnit 团队的自定义提供程序合并到他们的代码库中。

但是,您可以通过 User Guide 中描述的服务加载器机制注册您的自定义 TestExecutionListener