问题
We are developing an application based in an Embedded Infinispan Data-grid cluster. In the targeted environment of our application, each member of the data-grid will run in a independent JVM and using jgroup
the cluster will be formed (this is done by Infinispan actually).
For do some automated testing over this data-grid we were working with maven-surefire-plugin
(or maven-failsafe-plugin
) with this configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>perthread</forkMode>
<threadCount>4</threadCount>
</configuration>
</plugin>
Because this configuration should create a fork per each testcase class (using 4 parallel process) we create 4 test classes, where each one of them will simulate one cluster member. Inside each testcase class we will have several threads running in parallel the test methods thanks to TestNG like this:
@Test(threadPoolSize = 3, invocationCount = 2, timeOut = 10000, testName="Test 1")
public void testSomething() throws Throwable { ... }
The problem is that the maven-surefire-plugin
forkMode="perthread"
and threadCount=4
is buggy: It do not create one fork per class but a fork of the same class several times. So, in my scenario it takes one of the testcases and run it 4 times in parallel!!!
NOTE: check the jira bug here. Please vote!!!!
Do someone knows a workaround for this? We are doing some efforts using ant
but is getting very messy.
回答1:
The maven-surefire-plugin
bug was resolved and it will be released in the version 2.13!
Check the Jira ticket for more info: http://jira.codehaus.org/browse/SUREFIRE-869
来源:https://stackoverflow.com/questions/11098073/maven-surefire-failsafe-forkmode-perthread-is-not-working-a-workaround