How to use VSTest.Console.exe to get code coverage for changed files only

Alex 0 Reputation points
2025-01-08T12:37:00.34+00:00

Visual Studio Enterprise's Analyze Code Coverage function supports Changeset Report. I want to be able to get a code coverage changeset report i.e. report for only the changes files in my current branch from the command line by using VSTest.Console.exe. How do I do this ?

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.
353 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 32,406 Reputation points Microsoft Vendor
    2025-01-09T05:58:49.2933333+00:00

    Hello @Alex,

    Welcome to Microsoft Q&A forum.

    The "Configure Code Coverage Views" feature(includes viewing the changeset report) is a new feature(appears in VS 2022 Enterprise).

    There’s no direct command line option of VSTest.Console.exe to generate a code coverage changeset report. I checked the .runsettings file’s configuration elements, but didn’t find any corresponding parameter that support to generate a code coverage changeset report.

    I noticed that when exporting the test results(in VS), no options for filtering data and exporting different types of results/reports. By using the VSTest.Console.exe tool, it should be the same.

    I recommend you submit a suggestion ticket on our Developer Community for this feature. Currently, you may consider searching and use some VS extensions or try other methods to filter/regenerate the generated normal code coverage results/reports.

    Thanks for your understanding.

    Best Regards,

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.