2

I am trying to run a build with tests using the .runsettings file in VS 2017 and I want to exclude all the .dll files that have 'test' in their name I looked up some MSDN tutorials but I didn't find them useful. I was trying to do something like this. But it just fails the tests instead of actually excluding them

<exclude>
<objectSet>
<pattern type="File"> C:\* [test.dll] </pattern>
<pattern type="File"> C:\* [tests.dll] </pattern>
</objectSet>
</exclude>
AutoTester213
  • 2,714
  • 2
  • 24
  • 48
  • As far as I know, the `exclude` is using as codecoverage in runsettings file. `I want to exclude all the `.dll` files that have 'test' in their name.` Did you just want to exclude those tests not be executed or something else? Besides,, what's the result if you are using local VS with the same setting instead on TFS2017? – PatrickLu-MSFT May 22 '17 at 10:29
  • 1
    I found a solution .*\.tests\.* , Yes i wanted to exclude the tests not be to executed. – AutoTester213 May 22 '17 at 11:07

2 Answers2

2
<!--
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).

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

Source Link from MSDN: Using Regular Expressions in Visual Studio

You could use below exclude section with using .runsettings to exclude assemblies from code coverage

<ModulePath>.*tests.dll</ModulePath>
<ModulePath>.*Tests.dll</ModulePath>

or this

<ModulePath>.*\.tests\..*</ModulePath>
<ModulePath>.*\.Tests\..*</ModulePath>

More details please refer this similar question: How to exclude Projects with names ending in ".Test" from my code coverage analysis in VS2012 Unit Tests

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
0

Below one worked for me in .runSettings file.

<ModulePaths>
  <Exclude>
    <ModulePath>.*tests\.dll$</ModulePath>
    <ModulePath>.*test\.dll$</ModulePath>
  </Exclude>
 </ModulePaths>
owesom
  • 81
  • 4