How to use 2 surefire plugin configurations in 2 different profiles in the same pom

2.6k Views Asked by At

I am trying to run 2 profiles in a maven pom file. Each on of the profile use maven-sure-fire plugin and configuration:

<profiles>
    <profile>
        <id>profile1</id>
        <modules>
            <module>module1</module>
            <module>module-common</module>
        </modules>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/TestSuite1.java</include>
                                <include>**/*Test.java</include>
                            </includes>                             
                        </configuration>

                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>1.7</source>
                            <target>1.7</target>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>

    </profile>
    <profile>
        <id>profile2</id>
        <modules>
             <module>module2</module>
            <module>module-common</module>
        </modules>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/TestSuite2.java</include>
                                <include>**/*Test.java</include>
                            </includes>

                        </configuration>                           
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>1.7</source>
                            <target>1.7</target>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </profile>
</profiles>

When I run 1 profile The test are running in the same order they in the TestSuite but when I run 2 profiles The first profile run the tests in arbitrary order. The test are running in JUnit.

Any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

The problem is that maven optimize the profile and tests, you can create two different steps to run the profiles

Or (as you've probably done)

Create a third profile to include the two profile

In addition I think you have a typo in the CsatDistributionTest class name...

Ittiel