So I have issues running all the tests in my Maven project with Intellij. The reason for this is because a handful of modules are dependant on Native methods in a loaded dll. Since this dll can not be loaded more than once, I had to add a clause in my maven pom file that those tests would run in forked mode.
However, in Intellij I can not figure out how to make those same tests run as forked mode. I'd like to utilize the Intellij pretty UI for Unit tests with the green bar, and nice UT interfaces, however I can not run all tests in my project because of this issue.
Has anyone ever run into issues with Maven, Intellij and Unit tests and any tips on how to make them play nicely together?
Here is a snippet of my pom.xml file:
<plugin>
开发者_如何学JAVA <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>
Please vote for the feature request: Allow unit tests to be run seperate JVMs in IntelliJ IDEA issue tracker.
However, in Intellij I can not figure out how to make those same tests run as forked mode.
I don't think IntelliJ allows to tweak the behavior of its test runner.
Has anyone ever run into issues with Maven, Intellij and Unit tests and any tips on how to make them play nicely together?
Some ideas/suggestions:
- use Maven to run all the tests, even under IntelliJ ~or~
- use a TestSuite that does the DLL initialization and references all the TestCases, which of course no longer load the DLL.
In IntelliJ 14, you have Fork mode option in the Run Configuration dialog. When you're running all tests in a class/suite, you can enable forkMode=method that should be equivalent to your maven's pertest.
精彩评论