Maven:如何配置在集成测试阶段运行的测试?
我使用的是Maven 3.0.3。我想在测试阶段运行一些Junit测试,在集成测试阶段运行其他测试。问题是在集成测试阶段没有运行任何东西。我运行命令Maven:如何配置在集成测试阶段运行的测试?,maven,integration-testing,cargo,maven-cargo,maven-surefire-plugin,Maven,Integration Testing,Cargo,Maven Cargo,Maven Surefire Plugin,我使用的是Maven 3.0.3。我想在测试阶段运行一些Junit测试,在集成测试阶段运行其他测试。问题是在集成测试阶段没有运行任何东西。我运行命令 mvn clean install 开始一切。下面是我如何配置我的surefire插件 <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.6</v
mvn clean install
开始一切。下面是我如何配置我的surefire插件
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<skip>false</skip>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
<additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
</additionalClasspathElements>
<useManifestOnlyJar>false</useManifestOnlyJar>
<forkMode>always</forkMode>
<systemProperties>
<property>
<name>gwt.args</name>
<value>-out \${webAppDirectory}</value>
</property>
</systemProperties>
<excludes>
<exclude>**/integration/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/integration/**</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
maven surefire插件
2.6
假的
${project.build.sourceDirectory}
${project.build.testSourceDirectory}
假的
总是
gwt.args
-out\${webAppDirectory}
**/整合/**
集成测试
测试
假的
**/整合/**
我的“集成”目录中有两个JUnit测试。我正在使用Maven Cargo插件在集成阶段启动服务器。这是配置
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>tomcat${tomcat.major}x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url>
<downloadDir>${project.build.directory}/downloads</downloadDir>
<extractDir>${project.build.directory}/extracts</extractDir>
</zipUrlInstaller>
<output>${project.build.directory}/tomcat${tomcat.major}x.log</output>
<log>${project.build.directory}/cargo.log</log>
</container>
<configuration>
<home>${project.build.directory}/tomcat-${tomcat.version}/container</home>
<properties>
<cargo.logging>high</cargo.logging>
<cargo.servlet.port>${tomcat.servlet.port}</cargo.servlet.port>
<cargo.tomcat.ajp.port>${tomcat.ajb.port}</cargo.tomcat.ajp.port>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
<configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<pingURL>http://localhost:${tomcat.servlet.port}/${project.artifactId}</pingURL>
<pingTimeout>30000</pingTimeout>
<properties>
<context>${project.artifactId}</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
org.codehaus.cargo
cargo-maven2-plugin
tomcat${tomcat.major}x
http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz
${project.build.directory}/downloads
${project.build.directory}/extracts
${project.build.directory}/tomcat${tomcat.major}x.log
${project.build.directory}/cargo.log
${project.build.directory}/tomcat-${tomcat.version}/container
高的
${tomcat.servlet.port}
${tomcat.ajb.port}
启动容器
预集成测试
开始
部署
${project.groupId}
${project.artifactId}
战争
http://localhost:${tomcat.servlet.port}/${project.artifactId}
30000
${project.artifactId}
停止容器
整合后测试
停止
您知道我如何更改/增强配置以运行集成测试吗?-Dave看一看如果你想跑胜利圈,你能详细说明为什么尝试让surefire插件在测试和集成测试阶段都运行失败吗?@Dave请回答你的问题?你可以配置surefire在集成测试阶段运行,但这不是一个好主意。出现错误时,Surefire立即退出。Failsafe允许集成后测试maven生命周期阶段在出现故障后运行。TLDR:Surefire不允许清理,故障保护允许。