Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 633
Twaldigas Avatar asked Jan 29 '23 06:01

Twaldigas


1 Answers

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.

like image 81
Marc Philipp Avatar answered Feb 05 '23 17:02

Marc Philipp