unit-testingazure-devopsmicrosoft-fakes

azuredevops test code coverage result issues


I have a .net framework project and a test project in my solution ,when i ran the test,the code coverage result showed reasonable.But we I use azuredevops pipeline to run the tests and get code coverage result,It is different from local resut,some extra dll displayed on the result board.

enter image description here

I used some fake dlls and it seems that these dlls come from fakes dll.


Solution

  • It seems that I should specify the runsettings files and config include and exclude in the pipeline,the issues will be solved.

     <Configuration>
              <CodeCoverage>
                <!-- Match assembly file paths: -->
                <ModulePaths>
                  <Include>
                    <ModulePath>.*FunctionApp*.dll</ModulePath>
                    <!--<ModulePath>.*\.exe$</ModulePath>-->
                  </Include>
                  <Exclude>
                    <ModulePath>.*AutoGenerated.dll</ModulePath>
                    <ModulePath>.*Tests.dll</ModulePath>
                  </Exclude>
                </ModulePaths>
    
                <!-- We recommend you do not change the following values: -->
                <UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
                <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
                <CollectFromChildProcesses>True</CollectFromChildProcesses>
                <CollectAspDotNet>False</CollectAspDotNet>
    
              </CodeCoverage>
            </Configuration>
    

    and in the pipeline,specify the settings

    steps:
    - task: VSTest@2
      displayName: 'VsTest - testAssemblies'
      inputs:
        runSettingsFile: src/...../CodeCoverage.runsettings