IntelliJ IDEA:在代码覆盖率中忽略琐碎的方法 [英] IntelliJ IDEA: ignore trivial methods in code coverage

查看:714
本文介绍了IntelliJ IDEA:在代码覆盖率中忽略琐碎的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IntelliJ IDEA 15.0.2中,如何在测试覆盖率测量期间忽略琐碎的吸气剂和设定器(琐碎的方法)?

In IntelliJ IDEA 15.0.2 how can I ignore trivial getters and setters (trivial methods) during test coverage measurement?

// should be measure
public void complex() {
    fancy();
    interesting();
    dropDatabase();
}

// should not be measured
public int getNumber() {
    return this.number;
}

测量每一行将导致75%.仅通过上述方法进行测量将得出100%的结果.这些就是100%的可用于测试的代码.

Measuring every line would result in 75%. Measuring only the above method would result in 100%. And those are 100% of the code useful for testing.

为什么我在Internet上找不到任何信息?我会跳入不良习惯吗?

How come I don't find anything about that on the Internet? Am I diving into bad practice?


更新

此代码也可以进行测试:

This code is also eligible for testing:

// should also be tested as it contains logic
public Integer getValidationProgress() {
    if (validationProgress == null) {
        validationProgress = 0;
    }
    return validationProgress;
}

推荐答案

JetBrains告诉我,目前不可能.

JetBrains told me that this is currently not possible.

Andrey Dernov(IntelliJ)1月6日22:54

Andrey Dernov (IntelliJ) Jan 6, 22:54

迈克尔你好,

没有设置可以忽略某种方法.

There is no setting to ignore a certain method.

我为此创建了一个问题.

这篇关于IntelliJ IDEA:在代码覆盖率中忽略琐碎的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆