Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
993 views
in Technique[技术] by (71.8m points)

junit - Maven failsafe-plugin ignores thread number when run in parallel

I have this maven-failsafe-plugin execution config:

<plugin>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.16</version>
    <executions>
        <!-- ... other executions -->

        <execution>
            <id>multi-threaded-test-run</id>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
            <configuration>
                <skipITs>${skipParallel}</skipITs>
                <excludes>
                    <exclude>**/AA_*.java</exclude>
                    <exclude>**/ZZ_*.java</exclude>
                </excludes>
                <excludedGroups>com.snc.mobile.sg.core.attributes.SGNotThreadSafe</excludedGroups>
                <parallel>classesAndMethods</parallel>
                <threadCount>20</threadCount>
                <argLine>-XshowSettings:vm -Xms128m -Xmx3072m -XX:MaxMetaspaceSize=1024m</argLine>
            </configuration>
        </execution>

        <!-- ... other executions -->
    </executions>
     <dependencies>
          <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit47</artifactId>
            <version>2.17</version>
            <scope>compile</scope>
          </dependency>
    </dependencies>
<plugin>

When actually running the tests, Maven (or is it Junit?) seems to completely ignore any thread count I give it, running all the tests in parallel.

I've also tried other configurations, including setting parallel to just methods, and setting the more specific thread counts (threadCountClasses/threadCountMethods).

What am I doing wrong here?

P.S. Assume skipParallel is always false, that's not the issue, the execution does actually run.

Thanks, Avi.

question from:https://stackoverflow.com/questions/65867879/maven-failsafe-plugin-ignores-thread-number-when-run-in-parallel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Apparently, I wast missing <perCoreThreadCount>false</perCoreThreadCount>.

By default it's true, and it overrides the thread number you provide, despite it being called "optional" in the documentation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...