2017-07-02 256 views
0

我的公司开始使用SonarQube。 我看到它抱怨代码包含记录未覆盖的单元测试,例如:SonarQube抱怨Logger未被单元测试覆盖

LOGGER.debug("All sub merchants have been evicted from cache."); 

我们如何通过单元测试记录覆盖?

还有一个代码示例:

@Override 
    @TriggersRemove(removeAll = true, cacheName = TRUNCATE_PARAMS_CACHE_NAME, 
      keyGenerator = @KeyGenerator(name = CACHE_KEY_GENERATOR, 
        properties = @Property(name = "includeMethod", value = "false"))) 
    public void evictAll() { 
     LOGGER.info("Evicting all truncation candidates"); 
    } 
} 

声纳标记,其中记录器如出现未覆盖的单元测试线。

回答

0

Sonar抱怨没有记录确切的异常。

这应该做出警告走:

LOGGER.debug("All sub merchants have been evicted from cache.", e); 
+0

我有这样的一段代码,这也标记为未覆盖的,我想这是不是。 } catch(DataAccessException e){//发生机械错误。 LOGGER.error(“发生错误查询子数据。”,e); throw new RuntimeException(e); } –

+0

您能否发布确切的Sonar消息?代码示例也有帮助。 – Matej

+0

消息是:未被单元测试覆盖。 –

相关问题