Is there a way to configure a runsettings file to only check the actual project under test?

1.1k views Asked by At

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.

1

There are 1 answers

1
PatrickLu-MSFT On

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: