Arquillian 测试覆盖率

Arquillian test Coverage

我想查看 Arquillian 的 IT 测试 运行 测试覆盖率。我 运行 进入这个扩展:https://github.com/arquillian/arquillian-extension-jacoco

我不明白的是,为什么在报告中看不到由 JacocoInegrationTestCase 测试的 CoverageBean class。这就是我所期望的。
有人可以提供示例项目,在 Arquillian 上进行 1 个集成测试 运行ning 并测试 class 生成测试覆盖率报告吗?
谢谢

@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>

编辑: 我也尝试过这个项目 (https://github.com/CSchulz/arquillian-jacoco-showcase),看起来很有前途,但它 运行 反对 Wildfly 的发行版本。但在我的项目中,我们正在 运行ning Arquillian 测试再次安装JBOSS EAP 6 的实例,具有数据库连接和其他安全配置。是否有人能够更改它以使用 JBOSS 的已安装(已部署)版本?谢谢

根据您提供的信息,您似乎还没有执行 prepare-agent 目标。您可以在 README.

中查看完整示例

这是适合我的配置。看看对你有没有帮助。

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${version.plugin.maven.surefire}</version>
            <configuration>
                <failIfNoTests>false</failIfNoTests>
                <excludedGroups>org.jboss.arquillian.junit.Arquillian</excludedGroups>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${version.plugin.maven.failsafe}</version>
            <configuration>
                <groups>org.jboss.arquillian.junit.Arquillian</groups>
                <testFailureIgnore>false</testFailureIgnore>
                <systemPropertyVariables>
                    <arquillian.launch>jbossas-remote-7</arquillian.launch>
                </systemPropertyVariables>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco-plugin.version}</version>
            <configuration>
                <includes>
                </includes>
                <excludes>
                    <exclude>.....</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-prepare-agent-integration</id>
                    <goals>
                        <goal>prepare-agent-integration</goal>
                    </goals>
                    <configuration>
                        <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                    </configuration>
                </execution>
                <execution>
                    <id>Create Unit Test Report</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>Create Integration Test Report</id>
                    <goals>
                        <goal>report-integration</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>