Unit testing 有没有办法将runsettings文件配置为只检查测试中的实际项目?

Unit testing 有没有办法将runsettings文件配置为只检查测试中的实际项目?,unit-testing,visual-studio-2017,code-coverage,runsettings,Unit Testing,Visual Studio 2017,Code Coverage,Runsettings,我需要一种方法来动态设置runsettings文件,以便只检查测试中实际代码的代码覆盖率。这意味着排除任何nuget DLL。这需要在某种程度上是动态的,以便tfs生成定义可以使用它们。如果使用运行设置文件,则可以从代码覆盖范围中排除某些文件。Microsoft提供的示例注释说明: <!-- About include/exclude lists: Empty "Include" clauses imply all; empty "Exclude" clauses imply none.

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

如果使用运行设置文件,则可以从代码覆盖范围中排除某些文件。Microsoft提供的示例注释说明:

<!--
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>

*MyCompany\.Namespace\.Project\.dll$
*ThirdParty\.Namespace\.Project\.dll$
在本地环境中运行TFS build也是一样的,您只需要在TFS build pipeline的测试任务中指定相应的runsetting文件

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


  • 这是不可能的。这需要为tfs中的每个项目创建100个单独的共享测试步骤和运行设置文件。这也将使我们的标准无法执行。我需要一种方法来创建一个标准的测试设置文件,或者以一种标准的方式来配置它,以避免拉入nuget DLL。我们拥有的大多数nuget DLL都是公司内部的共享代码。