运行Maven Failsafe插件时出现问题

时间:2016-07-13 20:34:32

标签: maven-failsafe-plugin

我在使用mvn verify

运行故障安全插件时遇到问题

基本上它没有运行集成测试!如果我运行mvn failsafe:integration-test工作正常

另外,我是否需要jetty插件或类似程序来运行集成测试。

故障安全任务不一定要验证任务

代码已签入.. https://github.com/tonymurphy/builder

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>junit-stuff</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jxr-plugin</artifactId>
            <version>2.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.19.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.5.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.19</version>
                    <executions>
                        <execution>
                            <id>default-test</id>
                            <phase>none</phase>
                        </execution>
                        <execution>
                            <id>unit-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <includes>
                                    <include>**/*.java</include>
                                </includes>
                                <excludes>
                                    <exclude>**/*$*</exclude>
                                    <exclude>**/*ContractTest.java</exclude>
                                    <exclude>**/*MvcTest.java</exclude>
                                    <exclude>**/*_Test.java</exclude>
                                </excludes>
                                <excludedGroups>com.example.OneAtATime</excludedGroups>
                            </configuration>
                        </execution>
                        <execution>
                            <id>mvc-tests</id>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <includes>
                                    <include>**/*MvcTest.java</include>
                                </includes>
                                <excludedGroups>com.example.OneAtATime</excludedGroups>
                                <excludes>
                                    <exclude>**/*$*</exclude>
                                    <exclude>**/*ContractTest.java</exclude>
                                    <exclude>**/*_Test.java</exclude>
                                </excludes>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.19.1</version>
                    <executions>
                        <execution>
                            <id>integration-test</id>
                            <configuration>
                                <groups>com.example.OneAtATime</groups>
                            </configuration>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>9.2.2.v20140723</version>
                    <configuration>
                        <scanIntervalSeconds>10</scanIntervalSeconds>
                        <stopPort>8005</stopPort>
                        <stopKey>STOP</stopKey>
                    </configuration>
                    <executions>
                        <execution>
                            <id>start-jetty</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <!-- stop any previous instance to free up the port -->
                                <goal>stop</goal>
                                <goal>start</goal>
                            </goals>
                            <configuration>
                                <scanIntervalSeconds>0</scanIntervalSeconds>
                                <daemon>true</daemon>
                            </configuration>
                        </execution>
                        <execution>
                            <id>stop-jetty</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.19.1</version>
                <reportSets>
                    <reportSet>
                        <id>integration-tests</id>
                    <reports>
                        <report>failsafe-report-only</report>
                    </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
</project>

1 个答案:

答案 0 :(得分:0)

您需要为验证目标创建单独的执行:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    ...
    <executions>
        <execution>
            <id>integration-test</id>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
        <execution>
            <id>verify</id>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>