Could not run Code Coverage with VS2019 Enterprise

Levina Lioe 0 Reputation points
2023-03-21T19:33:06.3466667+00:00

I'm not able to run unit test with code coverage using Visual Studio 2019 Enterprise. I have Version 16.11.21 running on my system. Observed the following error message:

Failed to set up the execution context to run the test

Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
329 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,546 Reputation points Microsoft Vendor
    2023-03-22T03:15:06.8066667+00:00

    Hello @Levina Lioe ,

    Welcome to Microsoft Q&A forum.

    Please first try to create a new Unit Test project and run code coverage directly. Verify if the same error appears.

    If the same error appears, please try to repair Visual Studio(VS Installer => More => Repair) and reset Visual Studio settings(open Developer Command Prompt for VS 2019 Enterprise => run devenv /ResetSettings).

    If the Code Coverage runs successfully, please check if your project linked any references, used any references, and set any configurations. Make sure that all necessary dll/output files have been copied to the correct folder/output folder.

    Also, please verify that for each assembly, there’s .pdb file in the same directory(typicall bin\debug) as the .dll or .exe file. If you are using C++ project, verify that Linker => Debugging => Generate Debug Info is set to Generate Debug Information optimized for sharing and publishing (/DEBUG:FULL).

    Besides, was building and running the unit test project successfully passed?

    Please feel free to let us know the result.

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.