我希望看到 test coverage for IT tests 与Arquillian一起运行 . 我遇到了这个扩展:https://github.com/arquillian/arquillian-extension-jacoco
我不明白为什么 CoverageBean 测试的 CoverageBean 类在报告中不可见 . 多数民众赞成我所期待的 .
有人可以提供示例项目,在Arquillian和测试类上运行1个集成测试,生成测试覆盖率报告吗?
谢谢
@RunWith(Arquillian.class)
public class JacocoInegrationTestCase
{
@Deployment
public static JavaArchive createDeployment() throws Exception
{
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClasses(CoverageBean.class, JacocoInegrationTestCase.class);
}
@EJB
private CoverageBean bean;
@Test
public void shouldBeAbleToGenerateSomeTestCoverage() throws Exception
{
Assert.assertNotNull(bean);
bean.test(true);
}}
@Stateless
public class CoverageBean
{
public void test(Boolean value)
{
String test = "test";
if(value)
{
if(test.length() == 4)
{
long start = System.currentTimeMillis();
test = String.valueOf(start);
}
}
else
{
long start = System.currentTimeMillis();
test = String.valueOf(start);
}
}}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<environmentVariables>
<JBOSS_HOME>${jbossHome}</JBOSS_HOME>
</environmentVariables>
<skip>false</skip>
<includes>
<include>org/jboss/arquillian/extension/jacoco/test/unit/ * </include>
<include>org/jboss/arquillian/extension/jacoco/test/integration/ * </include>
</includes>
</configuration>
</execution>
EDIT: 我也尝试过这个项目(https://github.com/CSchulz/arquillian-jacoco-showcase),看起来非常有意义,但它运行Wildfly的分发版本 . 但在我的项目中,我们再次运行Arquillian测试安装的JBOSS EAP 6实例,具有数据库连接和其他安全配置 . 是否有人能够更改它以使用已安装(部署)的JBOSS版本?谢谢
2 回答
这是适合我的配置 . 看看它是否对你有所帮助 .
根据信息,你've provided, it looks like you haven' t执行
prepare-agent
目标 . 您可以在README中查看完整示例 .