为什么我的集成测试没有执行?

时间:2015-04-16 09:34:45

标签: integration-testing maven-surefire-plugin maven-failsafe-plugin

我使用surefire和failsafe分别执行单元测试,集成测试。所有测试都位于文件夹src/test/java中。到目前为止,我有一个集成测试类TaskAdditionIT.java,其测试方法(使用@Test注释)在运行所有单元测试时永远不会执行。这是我的pom.xml的摘录:

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

我使用maven目标verify来运行测试。

1 个答案:

答案 0 :(得分:0)

解决方案:

不要将executions嵌入configuration

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