Code Coverage Results da periódicamente: Resultados vacíos generados

I've run into a recurring problem with a few different projects using MSTest in VS2012, where every now and then my code coverage stops working (seemingly at random) and instead gives me:

Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see http://go.microsoft.com/fwlink/?LinkID=253731

I've checked the obvious (what it's suggested) but can't seem to figure out what is causing it.

Here is my runsettings file:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="Code Coverage"
                     uri="datacollector://Microsoft/CodeCoverage/2.0"
                     assemblyQualifiedName=" Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, 
                                             Microsoft.VisualStudio.TraceCollector, 
                                             Version=11.0.0.0, 
                                             Culture=neutral, 
                                             PublicKeyToken=b03f5f7f11d50a3a">
        <Configuration>
          <CodeCoverage>
            <ModulePaths>
              <Include>
                <ModulePath>.*\.dll$</ModulePath>
              </Include>
              <Exclude>
                <ModulePath>.*\.tests.dll</ModulePath>
              </Exclude>
            </ModulePaths>
            <Attributes>
              <Exclude>
                <Attribute>.*ExcludeFromCodeCoverageAttribute$</Attribute>
                <Attribute>.*GeneratedCodeAttribute$</Attribute>
              </Exclude>
            </Attributes>

            <UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
            <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
            <CollectFromChildProcesses>True</CollectFromChildProcesses>
            <CollectAspDotNet>False</CollectAspDotNet>
          </CodeCoverage>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

preguntado el 13 de septiembre de 13 a las 11:09

9 Respuestas

I just ran into this using Visual Studio 2019. The solution was to go to the "Test" menu item in VS and then update the Test -> Processor Architecture for AnyCPU Projects setting from X86 to X64.

respondido 13 mar '20, 19:03

This solved the problem for me in VS2019 16.4.2. Had a .Net Core 3.0 test project with 0% coverage. Change the platform target from "Any CPU" to "x64". Lo and behold, now it reports a coverage of 83%. - Michel Gammelgaard

Upvote! Also, screen shot here : stackoverflow.com/questions/59250411/… - granadaCoder

Este enlace resolvió mi problema: Problema con la cobertura de código en VS 2012

Close Visual Studio 2012, find the .suo file, delete (or rename) it, restart. Worked fine. No idea what is in the .suo file that prevented proper coverage analysis.

contestado el 23 de mayo de 17 a las 12:05

It helped but for I am using VS 2019, I had to delete .vs folder. - Dexterslab

If you can't make the Code Coverage to work even after you've deleted the *.suo file, please check your Visor de sucesos for errors. In my case, after each run I had the following error:

"TraceLog Profiler failed in initialization due to a lack of instrumentation methods, process vstest.executionengine.x86.exe"

He encontrado la respuesta aquí.

In case the link is no longer available, I'm pasting the content in here:

If you find yourself with a an empty .coverage file and see errors similar to the below in your event logs you most probably have a corrupt install

(info) .NET Runtime version 4.0.30319.17929 - The profiler has requested that the CLR instance not load the profiler into this process. Profiler CLSID: '{b19f184a-cc62-4137-9a6f-af0f91730165}'. Process ID (decimal): 12624. Message ID: [0x2516].

(Error) TraceLog Profiler failed in initialization due to a lack of instrumentation methods, process vstest.executionengine.x86.exe

Revise

a) Environment variable VS110COMNTOOLS is set to \common7\tools

b) Regkey HKLM\SOFTWARE\Microsoft\VisualStudio\11.0\InstallDir is set to your \Common7\IDE\

c) covrun32.dll and covrun64.dll exist in "\Team Tools\Dynamic Code Coverage"

Buena suerte,

Nadav

Respondido 12 Feb 14, 12:02

Thanks! Updating the environment variables fixed the problem for one of my devs who initially installed on C: and then reinstalled on D:. Uninstalling/ reinstalling didn't update the environment variables. - andreswhalan

I had a similar problem after running PerfView.

Re-running perfview having copied it into a folder of it's own and starting a collection run, followed by stopping it seems to have fixed the issue.

I was getting 0x8007007e errors loading the profiler with a guid of {9999995d-2cbb-4893-be09-fce80abc7564} (Vs2015 profiler) and {6652970f-1756-5d8d-0805-e9aad152aa84} (perfview profiler)

Espero que ayude a alguien más.

Respondido 28 Abr '16, 17:04

Parece que hay un error in Microsoft.NET.Test.Sdk 16.3.0+ which results in the same error output and currently the workaround is to downgrade to 16.2.0 which worked for me. In addition to the troubleshooting tips MS provides aquí there may be SDK issues.

Respondido el 09 de diciembre de 19 a las 21:12

Thank you! You solved my problem I was experiencing right now. - steven lemmens

In my case, the issue was that my test dll path contained the string "DataCollector" and seems coverlet has an internal ignore over any path that matches something like .*DataCollector.*

Respondido el 07 de junio de 21 a las 18:06

I modified the Property group associated with my debug environment so that it looks like this:

 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DocumentationFile>OurProjectName.xml</DocumentationFile>
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>

For my core.net 3.1 application running xUnit 2.4.1 this was the only thing that fixed it in visual studio 2019 preview.

respondido 05 mar '20, 19:03

Configure Test -> Processor Architecture >> AnyCPU Projects setting >>> X86 to X64.This works for me

contestado el 29 de mayo de 20 a las 18:05

I was also facing the same issue and tried out all the above options but it did not work for me.

I could solve this problem only after creating full debug information. The settings for full debug information may vary from version to version. As I am using MSVS 2017, in the build menu there is a submenu which allows to have the full debug version.

Espero que esto ayude a otros también.

Respondido 27 Oct 20, 12:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.