AutoTester213
AutoTester213

Reputation: 2862

.runsettings - Exclude All files with 'test'

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>

Upvotes: 2

Views: 2639

Answers (2)

osim_ans
osim_ans

Reputation: 457

Below one worked for me in .runSettings file.

<ModulePaths>
  <Exclude>
    <ModulePath>.*tests\.dll$</ModulePath>
    <ModulePath>.*test\.dll$</ModulePath>
  </Exclude>
 </ModulePaths>

Upvotes: 0

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51143

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

Upvotes: 2

Related Questions