4
votes

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.

1

1 Answers

8
votes

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.