【发布时间】:2014-01-29 09:26:28
【问题描述】:
我有一些集成测试可以使用带有命令的 surefire 插件完美运行:
mvn -Dtest=path.to.test.classIT surefire:test
当我使用故障安全插件运行相同的集成测试时
mvn verify
测试失败,表明它缺少依赖项(jackson lib,“No Message body writer found for response class”)。
需要的依赖项被添加到 pom 的范围测试中。 surefire 和 failsafe 执行测试的方式有什么区别?
更多上下文: 我的 pom 包含以下内容:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<forkMode>never</forkMode>
<threadCount>1</threadCount>
</configuration>
</plugin>
...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-cxf-rs</artifactId>
<version>4.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-mockito</artifactId>
<version>4.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<scope>provided</scope>
</dependency>
测试类使用applicationcomposer
@RunWith(ApplicationComposer.class)
public class PdaServiceIT {
....
@Configuration
public Properties config() throws Exception {
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
properties.setProperty("cxf.jaxrs.providers", "com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider");
return properties;
}
...
【问题讨论】:
-
您使用的是哪个版本的 maven-surefire、maven-failsafe?你能展示完整的pom吗?
-
对不起,版本来自父 pom。两个版本都是 2.12.4
标签: maven integration-testing maven-surefire-plugin maven-failsafe-plugin