如何设置GWT,maven,jacoco的覆盖范围? [英] How do I setup coverage with GWT, maven, jacoco?

查看:135
本文介绍了如何设置GWT,maven,jacoco的覆盖范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的GWT maven项目生成代码覆盖率.

I am trying to generate code coverage for my GWT maven project.

它与我的jUnit测试一起使用

It works with my jUnit test

mvn test jacoco:report

但是当我跑步

mvn gwt:test jacoco:report 

生成一个空报告.

运行gwt:tests时如何获得代码覆盖?

How does I get code coverage when I'm running the gwt:tests?

Pom.xml

GWT:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <version>2.5.1</version>
<configuration>
    <module>${gwtModule}</module>
    <gwtVersion>2.5.1</gwtVersion>
    <runTarget>https://localhost:8443/dashboard/mainview.jsp</runTarget>
    <noServer>true</noServer>
    <sourcesOnPath>true</sourcesOnPath>
    <hostedWebapp>${war.target}</hostedWebapp>
    <mode>HtmlUnit</mode>
</configuration>
<executions>
    <execution>
        <configuration>
            <extraJvmArgs>-Xmx512m</extraJvmArgs>
        </configuration>
        <goals>
            <goal>compile</goal>
            <goal>test</goal>
        </goals>
    </execution>
</executions>

Jacoco:

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.2.201302030002</version>
<configuration>
    <destfile>${basedir}/target/coverage-reports/jacoco-unit.exec</destfile>
    <datafile>${basedir}/target/coverage-reports/jacoco-unit.exec</datafile>
</configuration>
<executions>
    <execution>
        <id>jacoco-initialize</id>
        <goals>
            <goal>prepare-agent</goal>
        </goals>
    </execution>
    <execution>
        <id>jacoco-site</id>
        <phase>package</phase>
        <goals>
            <goal>report</goal>
        </goals>
    </execution>
</executions>

推荐答案

在命令行'

mvn help:describe -Dplugin=org.jboss.errai:jacoco-gwt-maven-plugin -Ddetail=true 

,您将从jacoco-gwt-maven-plugin获得详细的输出.在此列表中,您可以看到所有可以设置的配置参数.您得到的错误显示创建报告时出错:basedir c:\ Users ......不存在"与运行上面指定的命令时看到的snapshotDirectory设置有关.项目编译时,它将创建一个文件夹,其中放置了所有运行时类.您需要找到您的maven pom将这些类文件放在何处,然后在pom中指定此路径.因此,假设您的课程文件的路径位置是"target/test-classes",那么您的pom将是:

and you will get a detailed output from the jacoco-gwt-maven-plugin. In this list you can see all of the configuration parameters that can be set. The error you're getting where it says Error while creating report: basedir c:\Users...... does not exist is related to the snapshotDirectory setting that you see when you run the command I've specifed above. When your project compiles, it creates a folder where all your runtime classes are placed. You need to find where your maven pom is putting these class file and then specify this path in your pom. So say the path location for your class files is 'target/test-classes' then your pom will be:

<plugin>
  <groupId>org.jboss.errai</groupId>
  <artifactId>jacoco-gwt-maven-plugin</artifactId>
  <version>0.5.4.201202141554</version>
  <configuration>
    <snapshotDirectory>${project.build.directory}/test-classes</snapshotDirectory>
  </configuration>
</plugin>

还需要注意的另一件事是kesse,您的第一个问题与org.jacoco的jacoco-maven-plugin有关.使用此插件与GWT测试用例一起使用时,我也未能获得覆盖率结果.但是,上面的Thomas Broyer将您指向org.jboss.errai组的jacoco-gwt-maven-plugin.这个Errai小组是JBoss开发人员社区的一部分,这个插件与Errai框架有关.因此,为了使用GWT测试用例从Errai插件获取代码覆盖率结果,必须使用Errai框架.要了解有关Errai框架的更多信息,请访问 http://errai.github.io/.

Also one other thing to note kesse is that your initial question is to do with the jacoco-maven-plugin from org.jacoco. I've also failed to get coverage results with this plugin working with GWT Test Cases. However, Thomas Broyer above, points you towards the jacoco-gwt-maven-plugin from the org.jboss.errai group. This Errai group is part of the JBoss developer community and this plugin relates to the Errai Framework. So, in order to get code coverage results from the Errai plugin using the GWT Test Cases, you must use the Errai Framework. To find out more about the Errai Framework go to http://errai.github.io/.

这篇关于如何设置GWT,maven,jacoco的覆盖范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆