英文:
How to configure Jacoco Code Coverage for Web application
问题
我有一个基于模块化架构的 web 应用程序。该应用程序大约有数千个文件,现在我们需要使用 Jacoco 实施代码覆盖率。
Web 应用程序中使用的技术包括:
Spring、Hibernate、Ext.js、Mysql、Jersy、Tomcat 7.0.96、Maven
我不想编写任何 Junit、功能测试、集成测试,也就是说在代码方面不想有任何更改,关于代码覆盖率方面。
尝试过的解决方案:
找到了一些解决方案 -
- 将 Jacoco 的 jar 文件放置在 tomcat 中
- 配置 setenv.sh 以指向 jacoco 的 jar 文件
- 重启服务器
- 当服务器停止时,将生成 jacoco.exec 文件
- 将 pom.xml 和 web 包放置在 target 文件夹中
- 执行 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 -
- Place Jacoco jar files in tomcat
- Configure setenv.sh to point jacoc jar
- Restart server
- When Server are stopped jacoco.exec file will be generated.
- Place pom.xml and web package in target folder
- 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.
专注分享java语言的经验与见解,让所有开发者获益!
评论