Can't analyze code coverage with Visual Studio

2020-07-23 09:21发布

问题:

I'm using Visual Studio 2019 to develop and test a .NET Core application. A few months ago, I remember that all my tests are successful and I was able to launch a code coverage analyze. Today I launched a code coverage analyze but it fails (tests are always successful):

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 https://go.microsoft.com/fwlink/?LinkID=253731

I have always upgraded my Visual Studio and the current version I have now is Microsoft Visual Studio Enterprise 2019 (Version 16.4.0)

Any experience or feedback about this problem?

回答1:

Strange enough setting the "Processor Architecture" to x64 worked for me:

See screenshot



回答2:

In my case, with a fresh installed VS 2019 Enterprise and a simple solution with two projects:

  • static library
  • native unit test project (testing the library above)

I got the same error "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."

The solution was to enable "Profile" on the linker section of the native unit test project.