代码覆盖率jacoco踩坑篇

jacoco官网地址:https://www.eclemma.org/jacoco/

1、将项目压缩包上传至服务器

    rz

2、将项目解压

    unzip 项目压缩包

3、下载jacoco的jar包,解压

    wget  https://repo1.maven.org/maven2/org/jacoco/jacoco/0.8.6/jacoco-0.8.6.zip

    unzip  jacoco-0.8.6.zip

4、启动项目

    java -javaagent:jacocoagent.jar=includes=*,output=tcpserver,address=localhost,port=9999,destfile=./jacoco01.exec  -jar ./testManagerServerSpring-master/build/libs/testmananger-0.0.1.jar

    注意:port不能被占用,且端口需要被启用;destfile,生成的exec文件;

    查看端口被启用的端口:

        firewall-cmd --list-ports

    启用端口:

        firewall-cmd --zone=public --add-port=9999/tcp --permanent

        firewall-cmd --reload

    linux启用、关闭端口:https://blog.csdn.net/weixin_43911526/article/details/108906264

5、用postman发送请求,执行测试案例

6、java -jar jacococli.jar dump --address localhost --port 9999 --destfile jacoco01.exec

7、停掉服务

    查看进程:ps -ef | grep test

    杀死进程:kill -9 pid

8、java -jar jacococli.jar report jacoco01.exec --classfiles testManagerServerSpring-master/build/classes/java/main/ --sourcefiles testManagerServerSpring-master/src/main/java/   --html jacoco_01

    注意:classfiles、sourcefiles的路径为com包的上一层,否则生成的报告无法查看源代码;

9、将生成的jacoco_01压缩并下载

    zip -qr jacoco_01.zip  jacoco_01

    sz jacoco_01.zip

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值