I need a way to dynamically set a runsettings file to check code coverage only on the actual code under test. This means excluding any nuget dlls. This needs to be dynamic in some way so that tfs build definitions can use them.
Asked
Active
Viewed 995 times
1 Answers
0
If you use a run settings file you can exclude certain files from the code coverage. The comments of the Microsoft provided sample state that:
<!--
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.
-->
Add a sample for your reference:
<ModulePaths>
<Include>
<ModulePath>.*MyCompany\.Namespace\.Project\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*ThirdParty\.Namespace\.Project\.dll$</ModulePath>
</Exclude>
</ModulePaths>
It's the same to run TFS build on your locally environment, you just need to specify the corresponding runsetting file in your test task of TFS build pipeline.
Suggest you also take a look at below related blog:

PatrickLu-MSFT
- 49,478
- 5
- 35
- 62
-
This isn't feadible. This would require creating 100s of individual shared test steps and runsettings files for every project in our tfs. It would also make enforcement of our standards impossible. I need a way to make a standard test settings file, or a way to configure it in a standard way to not pull in nuget dlls. Most of the nuget dlls we have are shared code from within the company itself. – Rasen244 May 24 '18 at 16:51