title: How to exclude Projects with names ending in ".Test" from my code coverage analysis in VS2012 Unit Tests
body: <p>My solution is set up with projects called "ProjectName" with "ProjectName".Tests containing my unit tests. I'd like to exclude the test projects from the code coverage analysis under VS 2012 (MS Test) and have successfully managed to do this by adding the <code>ExcludeFromCodeCoverage</code> attribute to each test class as described <a href="http://msdn.microsoft.com/en-us/library/jj159530.aspx" rel="noreferrer">here</a>. </p>
  
  <p>As the number of tests classes is growing it would be nice to exclude the entire Test assemblies. I want to use the .runsettings file also described in that MSDN link but don't seem to be having any luck.</p>
  
  <p>Here is my .runsettings file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RunSettings&gt;
    &lt;DataCollectionRunSettings&gt;
      &lt;DataCollectors&gt;
        &lt;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"&gt;
          &lt;Configuration&gt;
            &lt;CodeCoverage&gt;
              &lt;ModulePaths&gt;
                &lt;Exclude&gt;
                  &lt;ModulePath&gt;.*tests.*&lt;/ModulePath&gt;
                  &lt;ModulePath&gt;.*Tests.*&lt;/ModulePath&gt;&gt;
                &lt;/Exclude&gt;
              &lt;/ModulePaths&gt;
            &lt;/CodeCoverage&gt;
          &lt;/Configuration&gt;
        &lt;/DataCollector&gt;
      &lt;/DataCollectors&gt;
    &lt;/DataCollectionRunSettings&gt;
  &lt;/RunSettings&gt;
  </code></pre>
  
  <p>This results in Empty results generated for Code Coverage, if I comment out the whole <code>&lt;Exclude&gt;</code> block I get code coverage across all of the solution's projects including the Tests (as expected, I just wanted to ensure that the addition of the runSettings file wasn't causing issues itself).</p>
  
  <p>I have tried adding in:</p>
  
  <pre><code>&lt;Include&gt;
    &lt;ModulePath&gt;.*\.dll$&lt;/ModulePath&gt;
    &lt;ModulePath&gt;.*\.exe$&lt;/ModulePath&gt;
  &lt;/Include&gt;
  </code></pre>
  
  <p>But again, I get Empty Results. I was under the impression that an empty (or non-existent) Include block will include everything by default <strong>unless</strong> matched by the Exclude block, so I don't think this is strictly required.</p>
  
  <p>Can anyone point me in the right direction? I see from <a href="https://stackoverflow.com/questions/12582025/how-to-exclude-tests-from-vs2012-test-runner">this other question</a> that I'm not alone in trying to exclude tests, but I would like to do it at assembly level and <a href="http://msdn.microsoft.com/en-us/library/jj159530.aspx" rel="noreferrer">MSDN</a> seems to suggest I can.</p>