0

I have an ASP.NET Core 9 Web API project and in the Azure DevOps pipeline, there are compiled files being collected for coverage - and there is no test code for those. For example the Mediator Library.

See this screen:

Pipeline Code Coverage Result

I have tried to add some configuration in .runsettings file.

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <Format>cobertura,opencover</Format>
           <Include>[MyCompany.*]*</Include>
          <Exclude>[*Test*]*</Exclude>
          <Exclude>[*Testes*]*</Exclude>
          <Exclude>[*.Testes.*]*</Exclude>
          <Exclude>[MyCompany.Formularios.Testes.*]*</Exclude>
          <Exclude>[*]*.libraries.*</Exclude>
          <ExcludeByFile>**/libraries/**</ExcludeByFile>
          <ExcludeByFile>**/bin/**</ExcludeByFile>
          <ExcludeByFile>**/obj/**</ExcludeByFile>
          <ExcludeByFile>**/*Testes.Shared*/**</ExcludeByFile>

          <ModulePaths>
              <Exclude>
               <ModulePath>.*Mediator*</ModulePath>
              </Exclude>
          </ModulePaths>
   
          <Attributes>
            <Exclude>
              <Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
              <Attribute>^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$</Attribute>
              <Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
              <Attribute>^Microsoft\.VisualStudio\.TestPlatform\.TestSDKAutoGeneratedCode.*$</Attribute>
            </Exclude>
          </Attributes>
          <IncludeTestAssembly>false</IncludeTestAssembly>
          <UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
          <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
          <CollectFromChildProcesses>True</CollectFromChildProcesses>
          <CollectAspDotNet>False</CollectAspDotNet>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

But it seems like it's not working correctly.

I have tried to update .runsettings with ModulePath.

The file that has been collected has the extension .g.cs:

File Information

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.