【问题标题】:Is there a way to configure a runsettings file to only check the actual project under test?有没有办法配置一个 runsettings 文件只检查被测的实际项目?
【发布时间】:2018-05-24 04:02:47
【问题描述】:

我需要一种方法来动态设置运行设置文件以仅检查实际测试代码的代码覆盖率。这意味着排除任何 nuget dll。这需要在某种程度上是动态的,以便 tfs 构建定义可以使用它们。

【问题讨论】:

    标签: unit-testing visual-studio-2017 code-coverage runsettings


    【解决方案1】:

    如果您使用运行设置文件,您可以将某些文件排除在代码覆盖范围之外。微软的 cmets 提供的示例状态是:

    <!--
    About include/exclude lists:
    Empty "Include" clauses imply all; empty "Exclude" clauses imply none.
    Each element in the list is a regular expression (ECMAScript syntax).
    See http://msdn.microsoft.com/library/2k3te2cs.aspx.
    An item must first match at least one entry in the include list to be included.
    Included items must then not match any entries in the exclude list to remain included.
    -->
    

    添加一个示例供您参考:

    <ModulePaths>
        <Include>
            <ModulePath>.*MyCompany\.Namespace\.Project\.dll$</ModulePath>
        </Include>
        <Exclude>
            <ModulePath>.*ThirdParty\.Namespace\.Project\.dll$</ModulePath>
        </Exclude>
    </ModulePaths>
    

    在本地环境下运行TFS build也是一样,只需要在TFS build pipeline的测试任务中指定对应的runsetting文件即可。

    建议你也看看下面的相关博客:

    【讨论】:

    • 这不可行。这将需要为我们的 tfs.xml 中的每个项目创建 100 个单独的共享测试步骤和运行设置文件。这也将使我们的标准无法执行。我需要一种制作标准测试设置文件的方法,或者一种以标准方式配置它以不引入 nuget dll 的方法。我们拥有的大多数 nuget dll 都是公司内部的共享代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多