Prevent unit tests but allow integration tests in Maven

前端 未结 7 796
無奈伤痛
無奈伤痛 2020-11-29 14:50

I\'ve a Maven build in which I use the SureFire plugin to run some unit tests, and the FailSafe plugin to run some integration tests. I would like a way to run just the Fai

相关标签:
7条回答
  • 2020-11-29 15:44

    I am using the code from Antonio Goncalves Blog , which works perfect.

    You can use the following properties:

    -DskipUTs=true for skipping surefire tests.

    -DskipITs=true for skipping failsafe tests.

    -DskipTests=true for skipping all tests.

    The pom.xml is as follows:

    <properties>
        <skipTests>false</skipTests>
        <skipITs>${skipTests}</skipITs>
        <skipUTs>${skipTests}</skipUTs>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <skipTests>${skipUTs}</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.19.1</version>
                <executions>
                    <execution>
                        <id>run-integration-tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skipTests>${skipTests}</skipTests>
                    <skipITs>${skipITs}</skipITs>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    0 讨论(0)
提交回复
热议问题