首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Arquillian测试覆盖率

Arquillian测试覆盖率
EN

Stack Overflow用户
提问于 2015-08-24 14:26:19
回答 2查看 3.6K关注 0票数 4

我希望看到针对IT测试的测试覆盖率与Arquillian一起运行。我遇到了一个分机:https://github.com/arquillian/arquillian-extension-jacoco

我不明白为什么JacocoInegrationTestCase测试的CoverageBean类在报告中不可见。这就是我所期望的。

请有人提供一个示例项目,在Arquillian和测试类上运行一个集成测试,并为其生成测试覆盖率报告。

谢谢

代码语言:javascript
复制
@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);

}}

代码语言:javascript
复制
@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);
  }

}}

代码语言:javascript
复制
 <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),看上去很混乱,但是它违背了野生蝇的发行版本。但是在我的项目中,我们使用数据库连接和其他安全配置,再次运行Arquillian测试JBOSS 6的安装实例。是否有人能够更改它以使用已安装(已部署)的JBOSS版本?谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-09-03 07:07:30

这是为我工作的配置。看看能不能帮上忙。

代码语言:javascript
复制
<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>
票数 2
EN

Stack Overflow用户

发布于 2015-08-25 13:38:24

根据您提供的信息,您似乎没有执行prepare-agent目标。您可以在自述文件中看到完整的示例。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32184782

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档