从 .net-core 中的代码覆盖率中排除类或方法 [英] Exclude class or method from code coverage in .net-core

查看:39
本文介绍了从 .net-core 中的代码覆盖率中排除类或方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用 [ExcludeFromCodeCoverage] 来排除 .Net framework 4 中的代码覆盖率.

I know i was able to use [ExcludeFromCodeCoverage] to exclude code coverage in .Net framework 4.

有谁知道是否有办法从 .dotnet 核心中排除代码覆盖率?

Does anyone know if there's a way i can exclude code coverage from .dotnet core?

推荐答案

从 .NET Core 2.0 开始,您可以使用 ExcludeFromCodeCoverage 属性.

Since .NET Core 2.0 you can use ExcludeFromCodeCoverage attribute.

using System.Diagnostics.CodeAnalysis;

namespace YourNamespace
{
    [ExcludeFromCodeCoverage]
    public class YourClass
    {
        ...
    }
}

https://isscroberto.com/2019/07/11/net-core-exclude-from-coverage/

这篇关于从 .net-core 中的代码覆盖率中排除类或方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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