简体   繁体   中英

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

I want to use JUnit 5 and the TestExecutionListener interface to do some clean up after the test run is done. The whole project is using JUnit Jupiter, no Vintage involved.

In Maven Surefire it was able to set a JUnit 4 RunListener via configuration to archive this. Is Surefire able to recognize the new JUnit 5 TestExecutionListener ? If not, is there any way to have JUnit 5 tests and use the TestExecutionListener or RunListener ?

I do not want to create my own Launcher just to execute tests with the listener.

Maven Surefire does currently not support adding a TestExecutionListener via its configuration. I think you should open an issue for them because they are currently incorporating the JUnit team's custom provider into their codebase.

However, you can register your custom TestExecutionListener via the Service Loader mechanism described in the User Guide .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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