鑒於上篇jacoco增量覆蓋率實踐實現了差異代碼獲取和jaocco二開后,很多咨詢我的是測試的小伙伴,對java可能不太熟悉,想要直接使用又趕腳稍許迷茫,所以又寫下這邊文章來幫助迷茫中的小伙伴拉
首先說明一下實現此增量方案所依賴的組件
- 原生jacoco知識
- code-diff服務
- 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主要四個參數:
file: At VM termination execution data is written to the file specified in thedestfileattribute.(當jvm停止掉的時候產出dump文件,即服務掛了產出dump文件)
tcpserver: The agent listens for incoming connections on the TCP port specified by theaddressandportattribute. Execution data is written to this TCP connection.(常用模式,將jacocoaget作為服務,每次通過cli包進行dump命令去獲取dump包)
tcpclient: At startup the agent connects to the TCP port specified by theaddressandportattribute. Execution data is written to this TCP connection.(將jacocoagent做為客戶端,向指定ip和端口的服務推送dump信息)
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 、修改application.yml
-
##基於git
-
git:
-
userName: admin
-
password: 123456
-
local:
-
base:
-
dir: D:\git-test
-
##基於svn
-
svn:
-
userName: admin
-
password: 123456
-
local:
-
base:
-
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地址,填寫差異分支的舊版本,新版本,執行,就可以獲取差異信息
-
{
-
"code": 10000,
-
"msg": "業務處理成功",
-
"data": [
-
{
-
"classFile": "com/dr/application/InstallCert",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/app/controller/Calculable",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/app/controller/JenkinsPluginController",
-
"methodInfos": null,
-
"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": null,
-
"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": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/app/param/AddRoleParam",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/app/vo/DependencyVO",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/app/vo/JenkinsPluginsVO",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/app/vo/RoleVO",
-
"methodInfos": null,
-
"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": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/config/JenkinsConfig",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/ddd/StaticTest",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/ddd/Test",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/application/util/GitAdapter",
-
"methodInfos": null,
-
"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": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/config/JenkinsConfigure",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/controller/JenkinsController",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/controller/TestApi",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/dto/JobAddDto",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/service/JenkinsService",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/service/impl/JenkinsServiceImpl",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/util/GenerateUniqueIdUtil",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/vo/DeviceVo",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/vo/GoodsVO",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/jenkins/vo/JobAddVo",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/repository/user/dto/query/RoleQueryDto",
-
"methodInfos": null,
-
"type": "ADD"
-
},
-
{
-
"classFile": "com/dr/repository/user/dto/result/RoleResultDto",
-
"methodInfos": null,
-
"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"
-
}
-
],
-
"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\"}]"
-
}
在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字段
-
java -jar org.jacoco.cli -0.8 .7-SNAPSHOT-nodeps.jar report jacoco.exec --classfiles \Desktop\feigin\web\build\classes
-
--classfiles \Desktop\feigin\biz\build\classes
-
--classfiles \Desktop\feigin\base\build\classes --sourcefiles \Desktop\feigin\web\src\main\java
-
--sourcefiles \Desktop\feigin\biz\src\main\java
-
--sourcefiles \Desktop\feigin\base\src\main\java --html report --xml jacoco.xml
-
--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\ "}]"
-
--encoding=utf8
最后我們總結下我們的增量方案
- cicd工具(devops服務)部署測試環境時備份源碼,編譯類
- 使用agent啟用應用服務
- 調用cli(二開)的dump命令生成exec文件
- 調用cli(二開)的report命令生成差異報告率(此處用到部署時備份的源碼和編譯類)
整個增量方案對原生jaocco基本無侵入,也不用源碼改造,歡迎大家一起找bug,哈哈,最最后匯總所有jacoco文章
jacoco的merge源碼分析
jacoco增量覆蓋率實踐
