Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify JUnit custom runner for Surefire Maven plugin?

Suppose I have a junit custom class loader, which reads the test data from a text file and create and run tests in runtime. The runner uses no test class.

Now I would like to run it with surefire maven plugin. That is, I would like to specify the runner as a parameter of the the surefire plugin "execution" in the pom.xml.

Can I do that?

like image 305
Michael Avatar asked Oct 17 '25 10:10

Michael


1 Answers

No. As far as I know, there is no way of specifying a Runner class in the maven-surefire-plugin. However, you should be able to create a single Test-Class and use the @RunWith(YourRunner.class) to let it run with your custom runner.

I think that is because the intended use case for Runners is on a per-test basis, not on a project-level. You can have a project with mixed uses of various Runners, e.g. some are Spring-based, some are concurrent, some run with JUnit3, some with JUnit4 etc.

like image 57
mhaller Avatar answered Oct 21 '25 04:10

mhaller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!