ubuntuGary
V2EX  ›  Java

求教,关于 IDEA 的本地 Coverage(代码覆盖率)统计问题!

  •  
  •   ubuntuGary · May 10, 2021 · 2992 views
    This topic created in 1854 days ago, the information mentioned may be changed or developed.
    IDEA 的本地 Coverage 扫描没有看到对条件语句分支覆盖统计,而 sonar 是要求有这部分覆盖统计的,导致提交代码是总是不符合公司要求。
    =====
    可能我的表述不太正确,我举个例子:
    代码中存在
    if (StringUtils.isNotBlank(str) && StringUtils.contains(str,",")) {
    // TODO
    }
    IDEA 不会统计,str = null || str = “test” || str = "test,test" 这三种情况的覆盖,而 sonar 的覆盖率统计是要求有的。
    Supplement 1  ·  May 17, 2021
    问题已解决,方法如下:
    TestNG:
    Edit Configurations -> Code Coverage -> Tracing
    JUnit:
    Edit Configurations -> Code Coverage -> Modify -> Use tracing


    1 replies    2021-05-10 09:22:28 +08:00
    cslive
        1
    cslive  
       May 10, 2021
    用 sonar 插件扫描
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1222 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:49 · PVG 07:49 · LAX 16:49 · JFK 19:49
    ♥ Do have faith in what you're doing.