简体   繁体   English

使用 mpirun 运行 Junit 测试,使用 maven surefire

[英]Running Junit tests with mpirun using maven surefire

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. 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.从上一个问题中的评论来看,OP 似乎能够通过创建一个专用脚本并在他的 ant 脚本引用该脚本的junit部分的jvm参数来实现这一点。

My question is : does an equivalent feature exist in maven firesafe?我的问题是:maven 防火中是否存在等效功能? Something that would allow me to change the "java" command used to an arbitrary script?可以让我将用于任意脚本的“java”命令更改为什么? Or should I create a specific ant script to call from maven?或者我应该创建一个特定的 ant 脚本以从 maven 调用?

Here is an exerpt of my pom.xml file:这是我的pom.xml文件的摘录:

         <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.我开发了自己的 Junit4 运行器,它为我创建了正确的mpirun -np X java -cp...命令并解析每个等级的测试结果。

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.由于使用自定义运行器是 Junit4 的标准功能,它与运行 Junit 测试的任何环境无缝集成,包括我特别感兴趣的 Maven Surefire(和 Failsafe)插件。

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/ ). 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/ ).

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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