문제

We have our POM defining the maven-surefire-plugin as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.14</version>
    <configuration>
        <reuseForks>false</reuseForks>
        <forkCount>1</forkCount>
        <argLine>-Xms64m -Xmx256m</argLine>
        <includes>
            <include>**/*Test.java</include>
        </includes>
    </configuration>
</plugin>

However, our Java tests (which involve some parallel tests and static singletons) only run properly when we run our test phase/build using:

mvn test -DforkMode=always

Strangely, even if we change our <configuration> to use (instead of the newer options):

<forkMode>always</forkMode>

And run:

mvn test

It will fail. But then if we run:

mvn test -DforkMode=always

It will pass. Instead of the newer options, it still will only work if we explicitly provide forkMode on the command line. We have tried this with multiple versions of the surefire plugin, to the same effect.

Are there any locations where this property could be overridden, or known issues in which the XML configuration is not properly used?

도움이 되었습니까?

해결책

Rookie mistake. The configuration I was using was listed in a separate <profile> block that was not being executed. The profile with:

<activeByDefault>true</activeByDefault>

Did not include its own Surefire configuration at all (so it didn't show up in a search), and was using inherited values, which explains why the command-line system properties were able to affect its behavior.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top