如何为Web应用配置Jacoco代码覆盖率

huangapple 未分类评论45阅读模式
英文:

How to configure Jacoco Code Coverage for Web application

问题

我有一个基于模块化架构的 web 应用程序。该应用程序大约有数千个文件,现在我们需要使用 Jacoco 实施代码覆盖率。

Web 应用程序中使用的技术包括:

Spring、Hibernate、Ext.js、Mysql、Jersy、Tomcat 7.0.96、Maven

我不想编写任何 Junit、功能测试、集成测试,也就是说在代码方面不想有任何更改,关于代码覆盖率方面。

尝试过的解决方案:

找到了一些解决方案 -

  1. 将 Jacoco 的 jar 文件放置在 tomcat 中
  2. 配置 setenv.sh 以指向 jacoco 的 jar 文件
  3. 重启服务器
  4. 当服务器停止时,将生成 jacoco.exec 文件
  5. 将 pom.xml 和 web 包放置在 target 文件夹中
  6. 执行 mvn jacoco:report

但是在 tomcat 7.0.96 中找不到 setev.sh 或 setev.bat 文件,我尝试在 catalina.bat 中进行相同的配置,但是没有生成 jacoco.exec 文件。

还请参考以下链接 -

http://crc83.blogspot.com/2017/05/how-to-mesure-code-coverage-on-tomcat.html
http://www.jacoco.org/jacoco/trunk/doc/agent.html

但无法连接并出现错误。

加载覆盖会话时出现错误 (code 5001)。

在地址 127.0.0.1、端口 6300 上连接 JaCoCo 代理时出现错误 (code 5006)。

连接被拒绝:无法连接

请为我提供一些解决方案,以实现最小更改,这样我就可以实施并检查我的应用程序代码覆盖率。

英文:

I have a web application with module based architecture. Application have around thousand of files, now we need to implement code coverage using Jacoco.

Technology Used in web application -

Spring, Hibernate, Ext.js, Mysql, Jersy, Tomcat 7.0.96, Maven

I don't want to write any Junit, functional, integration test, means nothing more changes in code side regarding to code coverage.

Tried Solutions -

Found some solutions -

  1. Place Jacoco jar files in tomcat
  2. Configure setenv.sh to point jacoc jar
  3. Restart server
  4. When Server are stopped jacoco.exec file will be generated.
  5. Place pom.xml and web package in target folder
  6. execute mvn jacoco:report

But unable to find setev.sh or setev.bat file inside tomcat 7.0.96, I tried same configuration inside catalina.bat but jacoco.exec file not generated.

also refer URL -

http://crc83.blogspot.com/2017/05/how-to-mesure-code-coverage-on-tomcat.html
http://www.jacoco.org/jacoco/trunk/doc/agent.html

but unable to connect and getting error.

Error while loading coverage session (code 5001).

Error while connecting to JaCoCo agent at address 127.0.0.1 on port 6300 (code 5006).

Connection refused: connect

Please suggest me some solution with min changes, so I will implement and check my application code coverage.

huangapple
  • 本文由 发表于 2020年4月3日 23:13:34
  • 转载请务必保留本文链接:https://java.coder-hub.com/61014952.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定