因此,我在使用 Intellij 运行 Maven 项目中的所有测试时遇到问题。原因是少数模块依赖于加载的 dll 中的本机方法。由于这个 dll 不能多次加载,我不得不在我的 maven pom 文件中添加一个子句,这些测试将以分叉模式运行。
但是,在 Intellij 中,我无法弄清楚如何使这些相同的测试以分叉模式运行。我想将 Intellij 漂亮的 UI 用于带有绿色条的单元测试和漂亮的 UT 接口,但是由于这个问题,我无法在我的项目中运行所有测试。
有没有人遇到过 Maven、Intellij 和单元测试的问题以及如何让它们很好地协同工作的任何提示?
这是我的 pom.xml 文件的片段:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>allTests</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>**/pkgA/**/*Test.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>forkedTests</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<forkMode>pertest</forkMode>
<includes>
<include>**/pkgA/**/*Test.java</include>
</includes>
<excludes>
<exclude>**/SpecificTest.java</exclude>
<exclude>**/*PerformanceTest.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>