使用.runsettings从程序集中排除名称空间

时间:2016-12-15 22:53:02

标签: c# visual-studio unit-testing code-coverage runsettings

我正在尝试从程序集Acme.Foundations.web.ext.dll排除所有名称空间,但是Acme.Foundations.Web.Ext.Controllers。请帮助创建一个runsettings文件。

<DataCollectionRunSettings>
     <DataCollectors>
        <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
           <Configuration>
             <CodeCoverage>
               <ModulePaths>
                 <Exclude>
                    <ModulePath>.*Ext.Helpers*</ModulePath>
                    ???
                 </Exclude>
               </ModulePaths>
             </CodeCoverage>
           </Configuration>
        </DataCollector>
     </DataCollectors>
  </DataCollectionRunSettings>

Acme.Foundations.web.ext.dll
Acme.Foundations.Web.Ext.Controllers
Acme.Foundations.Web.Ext.Helper
Acme.Foundations.Web.Ext.Models
Acme.Foundations.Web.Ext.Properties
Acme.Foundations.Web.Ext.Resources
Acme.Foundations.Web.Ext.Utilities
Acme.Foundations.Web.Ext.ViewModels
Acme.Identity.Web
Acme.Identity.Web.App_Start
Acme.Identity.Web.Identity
Acme.Utilities
System.Web.Mvc.Html

1 个答案:

答案 0 :(得分:8)

您必须使用功能 - &gt;排除部分并删除所有不需要的命名空间

例如:

<Functions>
     <Exclude>
        <!-- Exclude everthing inside the namesapce "Acme.Foundations.Web.Ext.Helper" --> 
        <Function>^Acme.Foundations.Web.Ext.Helper\..*</Function> 
     </Exclude>  
</Functions>