I would like to make some Junit tests using mpirun -n 4 java <relevant arguments>
, very similar to what was discussed in this question, but using maven surefire rather than ant.
From the comments in that previous question, it looks like the OP was able to achieve this by creating a dedicated script and having the jvm
parameter of the junit
part of his ant script reference that script.
My question is: does an equivalent feature exist in maven firesafe? Something that would allow me to change the "java" command used to an arbitrary script? Or should I create a specific ant script to call from maven?
Here is an exerpt of my pom.xml
file:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<!-- Specify a script with a relative path here ? -->
</configuration>
</plugin>
After a little work I ended up with quite a different solution than what I was expecting.
I developed my own Junit4 runner which creates the proper mpirun -np X java -cp...
command for me and parses the test results of each rank.
As using a custom runner is a standard feature of Junit4, it integrates seamlessly with any environment running Junit tests, including the Maven Surefire (and Failsafe) plugins which were of particular interest for me.
I will not develop the implementation details of how this custom Junit runner works but if you are interested, I just released it on GitHub (website: https://handist.github.io/mpi-junit/).