• 单元增量覆盖率工具设计


    命令:进入拉取的代码的目标地址:cd /root/workspace/pipeline_demo/test-v2-changedir-pipeline@2/test-v2-changedir-pipeline

    位置的变量名称:$PRO_HOME

    命令:git diff 1d5ae618de8ca82f0bbd5b14c639366964b9b808  30db05a3c2e5d09f672dbaba83bdb36a755b639d

    bash-4.4# cd ..
    diff --git a/src/main/java/com/yss/echo/swagger/Swagger2Configuration.java b/src/main/java/com/yss/echo/swagger/Swagger2Configuration.java
    index 269b658..a1bce35 100644
    --- a/src/main/java/com/yss/echo/swagger/Swagger2Configuration.java
    +++ b/src/main/java/com/yss/echo/swagger/Swagger2Configuration.java
    @@ -21,7 +21,7 @@ public class Swagger2Configuration {
    public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
    .select()
    - .apis(RequestHandlerSelectors.basePackage("com.yss"))
    + .apis(RequestHandlerSelectors.basePackage("com.hello"))
    .paths(PathSelectors.any())
    .build();
    }
    diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml
    index c42386d..17332f4 100644
    --- a/src/main/resources/bootstrap.yml
    +++ b/src/main/resources/bootstrap.yml
    @@ -65,8 +65,8 @@ management:

    java增量工具思想:https://www.cnblogs.com/cocc/p/12365950.html

    diff-cover:  https://www.jianshu.com/p/18c284cd3fa0

    1)循环读取gitdiff文件,如果当前行是以"diff --git"开头的,获取完整文件名,如:src/main/webapp/WEB-INF/default/jsp/tlfund/management/fund_transfer_record_list.jsp;

    2)如果当前行中包含"@@XXX @@"字样的,获取classname;

    3)如果当前行是以“-”开头的,跳过;

    4)过滤方法名:如果当前行不是以"+//"、“//”开头的,包含"private"或"public"和"(",且"function"、“=”、“if(”、"if ("、"for "、“for(”、“catch”、"logger."、“.”不在行内,且不是以";"结尾的,获取当前行并过滤出方法名;如果方法名不是"if"、"for"且"{"、"}"、"."、"+"、"@"不在行内的;将方法名添加到字典中,如果方法名已存在,将当前行添加到方法名的列表中;

    5)如果当前行是以"+"开头的,添加到对应的方法名列表中;

    6)最终返回{"文件名":{"diff_voids":{{方法名:[新增行]},'diff_lines':[所有新增行]}}的字典;

    本地操作:

    cd:  C:softwarecompanyapitestdemo arget

    java -javaagent:C:softwaremycodejacocojacoco-0.8.5libjacocoagent.jar=includes=*,output=tcpserver,port=6300,address=127.0.0.1,append=true,destfile=C:softwarecompanyapitestdemo argetcoverage.exec -jar boot1-0.0.1-SNAPSHOT.jar

    java -jar C:softwaremycodejacocojacoco-0.8.5libjacococli.jar dump --address 127.0.0.1 --port 6300 --destfile ./coverage.exec

    java -jar C:softwaremycodejacocojacoco-0.8.5libjacococli.jar report ./coverage.exec --classfiles C:softwarecompanyapitestdemo argetclassescom  --sourcefiles C:softwarecompanyapitestdemosrcmainjava --html report --xml report.xml

    git diff 8a90daf89a93e483b0b65593d8083d6daa297804  e97f65800fb5be4511980051d852225b742f105c

  • 相关阅读:
    js将url转换二维码
    百度地图api使用
    js字符串转日期兼容性
    Object.keys的使用
    Web App和Native App的比较
    数组转为对象
    常用meta整理
    git merge和git rebase的区别
    GitHub 翻译之 'Hello-world' 翻译
    js数据类型
  • 原文地址:https://www.cnblogs.com/wozhangdale1/p/12537510.html
Copyright © 2020-2023  润新知