jacoco 增量方案使用说明书


鉴于上篇jacoco增量覆盖率实践实现了差异代码获取和jaocco二开后,很多咨询我的是测试的小伙伴,对java可能不太熟悉,想要直接使用又赶脚稍许迷茫,所以又写下这边文章来帮助迷茫中的小伙伴拉

  • 组件说明

首先说明一下实现此增量方案所依赖的组件

  1. 原生jacoco知识
  2. code-diff服务
  3. jacoco二开cli包

原生jacoco知识

首先你需要了解jacoco的实现步骤,知道单元测试覆盖率和功能测试覆盖率,而我们通常讲的增量覆盖率一般讲的也是功能测试覆盖率

其实单元测试和功能测试其实分别对应jacoco的offline模式和on-the-fly模式

offline模式就是在测试之前先对文件进行插桩,生成插过桩的class或jar包,测试插过桩的class和jar包,生成覆盖率信息到文件,最后统一处理,生成报告。

而on-the-fly模式则是JVM通过 -javaagent参数指定jar文件启动代理程序,代理程序在ClassLoader装载一个class前判断是否修改class文件,并将探针插入class文件,探针不改变原有方法的行为,只是记录是否已经执行。

实现on-the-fly模式需要一下几个步骤

1.使用启动我们应用服务的时候,需要添加jvm参数 -javaagent,如:

  -javaagent:[yourpath/]jacocoagent.jar=[option1]=[value1],[option2]=[value2]
 

具体实例如下:

java -javaagent:/tmp/jacoco/lib/jacocoagent.jar=includes=*,output=tcpserver,port=6300,address=localhost,append=true -jar demo-0.0.1-SNAPSHOT.jar 
 

 

其中有个几个关键参数需要我们注意

  • includes=*

这个代表了,启动时需要进行字节码插桩的包过滤,*代表所有的class文件加载都需要进行插桩。

你可以写成:

includes=com.test.service.*
 

       这个参数我们可以用来做maven多模块的覆盖率,比如我们只想查看service服务层的覆盖率,我们可以通过设置包路径的方式进行只统计当前包的覆盖率

 

  • output=tcpserver     

       output主要四个参数:

  1. file: At VM termination execution data is written to the file specified in the destfile attribute.(当jvm停止掉的时候产出dump文件,即服务挂了产出dump文件)

  2. tcpserver: The agent listens for incoming connections on the TCP port specified by the address and port attribute. Execution data is written to this TCP connection.(常用模式,将jacocoaget作为服务,每次通过cli包进行dump命令去获取dump包)

  3. tcpclient: At startup the agent connects to the TCP port specified by the address and port attribute. Execution data is written to this TCP connection.(将jacocoagent做为客户端,向指定ip和端口的服务推送dump信息)

  4. none: Do not produce any output.(不产出任何dump,dump个寂寞,忽略)

此处需要有个说明:在k8s容器里面由于ip是动态的,tcpserver模式的ip无法固定填写,可以填 0.0.0.0 然后通过实际容器 ip 就可以访问到,而这个实际ip,一般可以从cmdb服务中动态获取

 

  • port=98080

这是jacoco开启的tcpserver的端口,请注意这个端口不能被占用

 

  • address=192.168.110.1

这是对外开发的tcpserver的访问地址。可以配置127.0.0.1,也可以配置为实际访问ip
配置为127.0.0.1的时候,dump数据只能在这台服务器上进行dump,就不能通过远程方式dump数据。
配置为实际的ip地址的时候,就可以在任意一台机器上(前提是ip要通,不通都白瞎),通过ant xml或者api方式dump数据。
举个栗子:
我如上配置了192.168.110.1:2014作为jacoco的tcpserver启动服务,
那我可以在任意一台机器上进行数据的dump,比如在我本机windows上用api或者xml方式调用dump。
如果我配置了127.0.0.1:2014作为启动服务器,那么我只能在这台测试机上进行dump,其他的机器都无法连接到这个tcpserver进行dump

如果不知道本机ip地址,可以使用0.0.0.0,这样ip地址会绑定主机ip

 

2.我们需要使用cli包去获取exec文件

java -jar jacococli.jar dump --address 192.169.110.1 --port 2014 --destfile ./jacoco-demo.exec
 

使用这个命令会在我们调用方的服务上生成一个exec文件

3.生成report

java -jar jacococli.jar report ./jacoco-demo.exec --classfiles /Users/oukotoshuu/IdeaProjects/demo/target/classes/com   --classfiles /Users/oukotoshuu/IdeaProjects/demo/target/classes/com --sourcefiles /Users/oukotoshuu/IdeaProjects/demo/src/main/java --sourcefiles /Users/oukotoshuu/IdeaProjects/demo/src/main/java --html report --xml report.xml
 

还是通过cli包去生成报告文件,注意这个classfiles和sourcefiles 可以是多个,我们如果是多模块项目通过指定代码路径和编译文件路径去分开做统计

 

以上就是jacoc原生知识点,相信大部分童鞋是清楚滴。

code-diff服务

code-diff一个获取增量代码的服务,支持git(分支,tag,commitid)和svn(分支,rversion),具体实现已经在上篇讲解到,这里只讲使用

首先拉取代码,修改配置文件,主要修改git服务的账号和密码,以及拉取代码的存储地址

  1.  
    1 、修改application.yml
  2.  
    ##基于git
  3.  
    git:
  4.  
    userName: admin
  5.  
    password: 123456
  6.  
    local:
  7.  
    base:
  8.  
    dir: D:\git-test
  9.  
    ##基于svn
  10.  
    svn:
  11.  
    userName: admin
  12.  
    password: 123456
  13.  
    local:
  14.  
    base:
  15.  
    dir: D:\svn-test

然后运行maven命令:

mvn  clean package -Dmaven.test.skip=true 
 

这样就可以获取到一个code-diff.jar包

找到一个服务器,将包扔上去,然后部署:

java -jar code-diff.jar
 

如此我们就算部署好差异代码服务了

运行项目,访问http://127.0.0.1:8085/doc.html(地址为部署服务ip)

git差异代码获取 svn差异代码获取 输入git地址,填写差异分支的旧版本,新版本,执行,就可以获取差异信息

  1.  
    {
  2.  
    "code": 10000,
  3.  
    "msg": "业务处理成功",
  4.  
    "data": [
  5.  
    {
  6.  
    "classFile": "com/dr/application/InstallCert",
  7.  
    "methodInfos": null,
  8.  
    "type": "ADD"
  9.  
    },
  10.  
    {
  11.  
    "classFile": "com/dr/application/app/controller/Calculable",
  12.  
    "methodInfos": null,
  13.  
    "type": "ADD"
  14.  
    },
  15.  
    {
  16.  
    "classFile": "com/dr/application/app/controller/JenkinsPluginController",
  17.  
    "methodInfos": null,
  18.  
    "type": "ADD"
  19.  
    },
  20.  
    {
  21.  
    "classFile": "com/dr/application/app/controller/LoginController",
  22.  
    "methodInfos": [
  23.  
    {
  24.  
    "methodName": "captcha",
  25.  
    "parameters": "HttpServletRequest&HttpServletResponse"
  26.  
    },
  27.  
    {
  28.  
    "methodName": "login",
  29.  
    "parameters": "LoginUserParam&HttpServletRequest"
  30.  
    },
  31.  
    {
  32.  
    "methodName": "testInt",
  33.  
    "parameters": "int&char"
  34.  
    },
  35.  
    {
  36.  
    "methodName": "testInt",
  37.  
    "parameters": "String&int"
  38.  
    },
  39.  
    {
  40.  
    "methodName": "testInt",
  41.  
    "parameters": "short&int"
  42.  
    },
  43.  
    {
  44.  
    "methodName": "testInt",
  45.  
    "parameters": "int[]"
  46.  
    },
  47.  
    {
  48.  
    "methodName": "testInt",
  49.  
    "parameters": "T[]"
  50.  
    },
  51.  
    {
  52.  
    "methodName": "testInt",
  53.  
    "parameters": "Calculable&int&int"
  54.  
    },
  55.  
    {
  56.  
    "methodName": "testInt",
  57.  
    "parameters": "Map<String,Object>&List<String>&Set<Integer>"
  58.  
    },
  59.  
    {
  60.  
    "methodName": "display",
  61.  
    "parameters": ""
  62.  
    },
  63.  
    {
  64.  
    "methodName": "a",
  65.  
    "parameters": "InnerClass"
  66.  
    }
  67.  
    ],
  68.  
    "type": "MODIFY"
  69.  
    },
  70.  
    {
  71.  
    "classFile": "com/dr/application/app/controller/RoleController",
  72.  
    "methodInfos": null,
  73.  
    "type": "ADD"
  74.  
    },
  75.  
    {
  76.  
    "classFile": "com/dr/application/app/controller/TestController",
  77.  
    "methodInfos": [
  78.  
    {
  79.  
    "methodName": "test",
  80.  
    "parameters": ""
  81.  
    },
  82.  
    {
  83.  
    "methodName": "getPom",
  84.  
    "parameters": "HttpServletResponse"
  85.  
    },
  86.  
    {
  87.  
    "methodName": "getDeList",
  88.  
    "parameters": ""
  89.  
    }
  90.  
    ],
  91.  
    "type": "MODIFY"
  92.  
    },
  93.  
    {
  94.  
    "classFile": "com/dr/application/app/controller/view/RoleViewController",
  95.  
    "methodInfos": null,
  96.  
    "type": "ADD"
  97.  
    },
  98.  
    {
  99.  
    "classFile": "com/dr/application/app/param/AddRoleParam",
  100.  
    "methodInfos": null,
  101.  
    "type": "ADD"
  102.  
    },
  103.  
    {
  104.  
    "classFile": "com/dr/application/app/vo/DependencyVO",
  105.  
    "methodInfos": null,
  106.  
    "type": "ADD"
  107.  
    },
  108.  
    {
  109.  
    "classFile": "com/dr/application/app/vo/JenkinsPluginsVO",
  110.  
    "methodInfos": null,
  111.  
    "type": "ADD"
  112.  
    },
  113.  
    {
  114.  
    "classFile": "com/dr/application/app/vo/RoleVO",
  115.  
    "methodInfos": null,
  116.  
    "type": "ADD"
  117.  
    },
  118.  
    {
  119.  
    "classFile": "com/dr/application/config/ExceptionAdvice",
  120.  
    "methodInfos": [
  121.  
    {
  122.  
    "methodName": "handleException",
  123.  
    "parameters": "Exception"
  124.  
    },
  125.  
    {
  126.  
    "methodName": "handleMissingServletRequestParameterException",
  127.  
    "parameters": "MissingServletRequestParameterException"
  128.  
    }
  129.  
    ],
  130.  
    "type": "MODIFY"
  131.  
    },
  132.  
    {
  133.  
    "classFile": "com/dr/application/config/GitConfig",
  134.  
    "methodInfos": null,
  135.  
    "type": "ADD"
  136.  
    },
  137.  
    {
  138.  
    "classFile": "com/dr/application/config/JenkinsConfig",
  139.  
    "methodInfos": null,
  140.  
    "type": "ADD"
  141.  
    },
  142.  
    {
  143.  
    "classFile": "com/dr/application/ddd/StaticTest",
  144.  
    "methodInfos": null,
  145.  
    "type": "ADD"
  146.  
    },
  147.  
    {
  148.  
    "classFile": "com/dr/application/ddd/Test",
  149.  
    "methodInfos": null,
  150.  
    "type": "ADD"
  151.  
    },
  152.  
    {
  153.  
    "classFile": "com/dr/application/util/GitAdapter",
  154.  
    "methodInfos": null,
  155.  
    "type": "ADD"
  156.  
    },
  157.  
    {
  158.  
    "classFile": "com/dr/common/errorcode/BizCode",
  159.  
    "methodInfos": [
  160.  
    {
  161.  
    "methodName": "getCode",
  162.  
    "parameters": ""
  163.  
    }
  164.  
    ],
  165.  
    "type": "MODIFY"
  166.  
    },
  167.  
    {
  168.  
    "classFile": "com/dr/common/response/ApiResponse",
  169.  
    "methodInfos": [
  170.  
    {
  171.  
    "methodName": "success",
  172.  
    "parameters": ""
  173.  
    }
  174.  
    ],
  175.  
    "type": "MODIFY"
  176.  
    },
  177.  
    {
  178.  
    "classFile": "com/dr/jenkins/JenkinsApplication",
  179.  
    "methodInfos": null,
  180.  
    "type": "ADD"
  181.  
    },
  182.  
    {
  183.  
    "classFile": "com/dr/jenkins/config/JenkinsConfigure",
  184.  
    "methodInfos": null,
  185.  
    "type": "ADD"
  186.  
    },
  187.  
    {
  188.  
    "classFile": "com/dr/jenkins/controller/JenkinsController",
  189.  
    "methodInfos": null,
  190.  
    "type": "ADD"
  191.  
    },
  192.  
    {
  193.  
    "classFile": "com/dr/jenkins/controller/TestApi",
  194.  
    "methodInfos": null,
  195.  
    "type": "ADD"
  196.  
    },
  197.  
    {
  198.  
    "classFile": "com/dr/jenkins/dto/JobAddDto",
  199.  
    "methodInfos": null,
  200.  
    "type": "ADD"
  201.  
    },
  202.  
    {
  203.  
    "classFile": "com/dr/jenkins/service/JenkinsService",
  204.  
    "methodInfos": null,
  205.  
    "type": "ADD"
  206.  
    },
  207.  
    {
  208.  
    "classFile": "com/dr/jenkins/service/impl/JenkinsServiceImpl",
  209.  
    "methodInfos": null,
  210.  
    "type": "ADD"
  211.  
    },
  212.  
    {
  213.  
    "classFile": "com/dr/jenkins/util/GenerateUniqueIdUtil",
  214.  
    "methodInfos": null,
  215.  
    "type": "ADD"
  216.  
    },
  217.  
    {
  218.  
    "classFile": "com/dr/jenkins/vo/DeviceVo",
  219.  
    "methodInfos": null,
  220.  
    "type": "ADD"
  221.  
    },
  222.  
    {
  223.  
    "classFile": "com/dr/jenkins/vo/GoodsVO",
  224.  
    "methodInfos": null,
  225.  
    "type": "ADD"
  226.  
    },
  227.  
    {
  228.  
    "classFile": "com/dr/jenkins/vo/JobAddVo",
  229.  
    "methodInfos": null,
  230.  
    "type": "ADD"
  231.  
    },
  232.  
    {
  233.  
    "classFile": "com/dr/repository/user/dto/query/RoleQueryDto",
  234.  
    "methodInfos": null,
  235.  
    "type": "ADD"
  236.  
    },
  237.  
    {
  238.  
    "classFile": "com/dr/repository/user/dto/result/RoleResultDto",
  239.  
    "methodInfos": null,
  240.  
    "type": "ADD"
  241.  
    },
  242.  
    {
  243.  
    "classFile": "com/dr/user/service/impl/PermissionServiceImpl",
  244.  
    "methodInfos": [
  245.  
    {
  246.  
    "methodName": "getPermissionByRoles",
  247.  
    "parameters": "List<Long>"
  248.  
    },
  249.  
    {
  250.  
    "methodName": "buildMenuTree",
  251.  
    "parameters": "List<MenuDTO>"
  252.  
    },
  253.  
    {
  254.  
    "methodName": "getSubMenus",
  255.  
    "parameters": "Long&Map<Long,List<MenuDTO>>"
  256.  
    }
  257.  
    ],
  258.  
    "type": "MODIFY"
  259.  
    },
  260.  
    {
  261.  
    "classFile": "com/dr/user/service/impl/RoleServiceImpl",
  262.  
    "methodInfos": [
  263.  
    {
  264.  
    "methodName": "getByUserId",
  265.  
    "parameters": "Long"
  266.  
    },
  267.  
    {
  268.  
    "methodName": "getListByPage",
  269.  
    "parameters": "RoleQueryDto"
  270.  
    }
  271.  
    ],
  272.  
    "type": "MODIFY"
  273.  
    }
  274.  
    ],
  275.  
    "uniqueData": "[{\"classFile\":\"com/dr/application/InstallCert\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/app/controller/Calculable\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/app/controller/JenkinsPluginController\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/app/controller/LoginController\",\"methodInfos\":[{\"methodName\":\"captcha\",\"parameters\":\"HttpServletRequest&HttpServletResponse\"},{\"methodName\":\"login\",\"parameters\":\"LoginUserParam&HttpServletRequest\"},{\"methodName\":\"testInt\",\"parameters\":\"int&char\"},{\"methodName\":\"testInt\",\"parameters\":\"String&int\"},{\"methodName\":\"testInt\",\"parameters\":\"short&int\"},{\"methodName\":\"testInt\",\"parameters\":\"int[]\"},{\"methodName\":\"testInt\",\"parameters\":\"T[]\"},{\"methodName\":\"testInt\",\"parameters\":\"Calculable&int&int\"},{\"methodName\":\"testInt\",\"parameters\":\"Map<String,Object>&List<String>&Set<Integer>\"},{\"methodName\":\"display\",\"parameters\":\"\"},{\"methodName\":\"a\",\"parameters\":\"InnerClass\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/application/app/controller/RoleController\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/app/controller/TestController\",\"methodInfos\":[{\"methodName\":\"test\",\"parameters\":\"\"},{\"methodName\":\"getPom\",\"parameters\":\"HttpServletResponse\"},{\"methodName\":\"getDeList\",\"parameters\":\"\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/application/app/controller/view/RoleViewController\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/app/param/AddRoleParam\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/app/vo/DependencyVO\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/app/vo/JenkinsPluginsVO\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/app/vo/RoleVO\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/config/ExceptionAdvice\",\"methodInfos\":[{\"methodName\":\"handleException\",\"parameters\":\"Exception\"},{\"methodName\":\"handleMissingServletRequestParameterException\",\"parameters\":\"MissingServletRequestParameterException\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/application/config/GitConfig\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/config/JenkinsConfig\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/ddd/StaticTest\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/ddd/Test\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/application/util/GitAdapter\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/common/errorcode/BizCode\",\"methodInfos\":[{\"methodName\":\"getCode\",\"parameters\":\"\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/common/response/ApiResponse\",\"methodInfos\":[{\"methodName\":\"success\",\"parameters\":\"\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/jenkins/JenkinsApplication\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/config/JenkinsConfigure\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/controller/JenkinsController\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/controller/TestApi\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/dto/JobAddDto\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/service/JenkinsService\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/service/impl/JenkinsServiceImpl\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/util/GenerateUniqueIdUtil\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/vo/DeviceVo\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/vo/GoodsVO\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/jenkins/vo/JobAddVo\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/repository/user/dto/query/RoleQueryDto\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/repository/user/dto/result/RoleResultDto\",\"methodInfos\":[],\"type\":\"ADD\"},{\"classFile\":\"com/dr/user/service/impl/PermissionServiceImpl\",\"methodInfos\":[{\"methodName\":\"getPermissionByRoles\",\"parameters\":\"List<Long>\"},{\"methodName\":\"buildMenuTree\",\"parameters\":\"List<MenuDTO>\"},{\"methodName\":\"getSubMenus\",\"parameters\":\"Long&Map<Long,List<MenuDTO>>\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/user/service/impl/RoleServiceImpl\",\"methodInfos\":[{\"methodName\":\"getByUserId\",\"parameters\":\"Long\"},{\"methodName\":\"getListByPage\",\"parameters\":\"RoleQueryDto\"}],\"type\":\"MODIFY\"}]"
  276.  
    }

在linux系统部署时请注意修改代码的基础路径和日志路径,如:

java -jar  -Dlog.path=/app/data2/devops/code-diff/logs  -Dgit.local.base.dir=/app/dat code-diff.jar
 

其中字段uniqueData的值为序列化差异代码的值,后续我们获取差异代码直接使用这个值即可,code-diff就是一个正常的java springboot项目,在我们使用时可以通过接口调用获取到差异代码再进行其他步骤

jacoco二开

jacoco二开主要是对cli包的改造,同时匹配code-diff产生的代码格式进行匹配,这里同样只讲使用

我们可以拿到jacoco二开代码进行编译获取我们的cli包,当然你也可以直接使用,我已经打好了包,下载地址。另外启用服务时用的agent包可以使用我的也可以不使用我的,没什么关系。

用法和原生jacoco一模一样,只是如果你要获取增量代码覆盖率,需要传递一个--diffCode的参数,其中--encoding=utf8为了防止报告乱码,diffCode为code-diff服务获取的uniqueData字段

  1.  
    java -jar org.jacoco.cli -0.8 .7-SNAPSHOT-nodeps.jar report jacoco.exec --classfiles \Desktop\feigin\web\build\classes
  2.  
    --classfiles \Desktop\feigin\biz\build\classes
  3.  
    --classfiles \Desktop\feigin\base\build\classes --sourcefiles \Desktop\feigin\web\src\main\java
  4.  
    --sourcefiles \Desktop\feigin\biz\src\main\java
  5.  
    --sourcefiles \Desktop\feigin\base\src\main\java --html report --xml jacoco.xml
  6.  
    --diffCode "[{\"classFile\ ":\"com/dr/application/InstallCert\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/app/controller/Calculable\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/app/controller/JenkinsPluginController\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/app/controller/LoginController\ ",\"methodInfos\ ":[{\"methodName\ ":\"captcha\ ",\"parameters\ ":\"HttpServletRequest&HttpServletResponse\ "},{\"methodName\ ":\"login\ ",\"parameters\ ":\"LoginUserParam&HttpServletRequest\ "},{\"methodName\ ":\"testInt\ ",\"parameters\ ":\" int&char\ "},{\"methodName\ ":\"testInt\ ",\"parameters\ ":\" String& int\ "},{\"methodName\ ":\"testInt\ ",\"parameters\ ":\"short& int\ "},{\"methodName\ ":\"testInt\ ",\"parameters\ ":\" int[]\ "},{\"methodName\ ":\"testInt\ ",\"parameters\ ":\"T[]\ "},{\"methodName\ ":\"testInt\ ",\"parameters\ ":\"Calculable& int& int\ "},{\"methodName\ ":\"testInt\ ",\"parameters\ ":\"Map< String,Object>&List< String>& Set<Integer>\ "},{\"methodName\ ":\"display\ ",\"parameters\ ":\"\ "},{\"methodName\ ":\"a\ ",\"parameters\ ":\"InnerClass\ "}],\"type\ ":\"MODIFY\ "},{\"classFile\ ":\"com/dr/application/app/controller/RoleController\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/app/controller/TestController\ ",\"methodInfos\ ":[{\"methodName\ ":\"test\ ",\"parameters\ ":\"\ "},{\"methodName\ ":\"getPom\ ",\"parameters\ ":\"HttpServletResponse\ "},{\"methodName\ ":\"getDeList\ ",\"parameters\ ":\"\ "}],\"type\ ":\"MODIFY\ "},{\"classFile\ ":\"com/dr/application/app/controller/view/RoleViewController\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/app/param/AddRoleParam\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/app/vo/DependencyVO\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/app/vo/JenkinsPluginsVO\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/app/vo/RoleVO\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/config/ExceptionAdvice\ ",\"methodInfos\ ":[{\"methodName\ ":\"handleException\ ",\"parameters\ ":\"Exception\ "},{\"methodName\ ":\"handleMissingServletRequestParameterException\ ",\"parameters\ ":\"MissingServletRequestParameterException\ "}],\"type\ ":\"MODIFY\ "},{\"classFile\ ":\"com/dr/application/config/GitConfig\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/config/JenkinsConfig\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/ddd/StaticTest\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/ddd/Test\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/application/util/GitAdapter\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/common/errorcode/BizCode\ ",\"methodInfos\ ":[{\"methodName\ ":\"getCode\ ",\"parameters\ ":\"\ "}],\"type\ ":\"MODIFY\ "},{\"classFile\ ":\"com/dr/common/ response/ApiResponse\ ",\"methodInfos\ ":[{\"methodName\ ":\"success\ ",\"parameters\ ":\"\ "}],\"type\ ":\"MODIFY\ "},{\"classFile\ ":\"com/dr/jenkins/JenkinsApplication\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/config/JenkinsConfigure\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/controller/JenkinsController\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/controller/TestApi\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/dto/JobAddDto\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/service/JenkinsService\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/service/impl/JenkinsServiceImpl\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/util/GenerateUniqueIdUtil\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/vo/DeviceVo\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/vo/GoodsVO\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/jenkins/vo/JobAddVo\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/repository/user/dto/query/RoleQueryDto\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/repository/user/dto/result/RoleResultDto\ ",\"methodInfos\ ":[],\"type\ ":\"ADD\ "},{\"classFile\ ":\"com/dr/user/service/impl/PermissionServiceImpl\ ",\"methodInfos\ ":[{\"methodName\ ":\"getPermissionByRoles\ ",\"parameters\ ":\"List<Long>\ "},{\"methodName\ ":\"buildMenuTree\ ",\"parameters\ ":\"List<MenuDTO>\ "},{\"methodName\ ":\"getSubMenus\ ",\"parameters\ ":\"Long&Map<Long,List<MenuDTO>>\ "}],\"type\ ":\"MODIFY\ "},{\"classFile\ ":\"com/dr/user/service/impl/RoleServiceImpl\ ",\"methodInfos\ ":[{\"methodName\ ":\"getByUserId\ ",\"parameters\ ":\"Long\ "},{\"methodName\ ":\"getListByPage\ ",\"parameters\ ":\"RoleQueryDto\ "}],\"type\ ":\"MODIFY\ "}]"
  7.  
    --encoding=utf8

最后我们总结下我们的增量方案

  • cicd工具(devops服务)部署测试环境时备份源码,编译类
  • 使用agent启用应用服务
  • 调用cli(二开)的dump命令生成exec文件
  • 调用cli(二开)的report命令生成差异报告率(此处用到部署时备份的源码和编译类)

整个增量方案对原生jaocco基本无侵入,也不用源码改造,欢迎大家一起找bug,哈哈,最最后汇总所有jacoco文章

 

jacoco的merge源码分析

jacoco增量覆盖率实践

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM