Code Coverage with WinAppDriver

Xuyang Song 6 Reputation points
2021-02-16T09:01:00.203+00:00

Hi,

Recently, we are looking at the option of moving from coded UI tests to WinAppDriver for testing our windows based WPF applications. But we can't find a way to get code coverage for the application code. Is code coverage supported by WinAppDriver? If not, what is the recommended approach for UI automation tests that could provide code coverage?

Thanks!
Xuyang

Developer technologies | Windows Presentation Foundation
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. DaisyTian-1203 11,651 Reputation points Moderator
    2021-02-17T08:14:50.687+00:00

    You can get the Code Coverage Results for the Application in Visual Studio by the steps: Test>Code Coverage Results (My Visual Studio is Enterprise 2019 Version 16.8.3). WinAppDriver supports performing UI automation against Windows applications, regardless of the technology used to build it (UWP, WPF, Windows Forms, Win32, etc.).

    Here is my steps to use WinAppDriver to test the project.
    1.Install WinAppDriver from here.
    2.Download the demo from UI Testing for WPF apps.
    3.Update the WpfAppId in WpfUiTesting.Tests according to your environment.
    4.Open Analyze Code Coverage for All Tests by steps Test>Analyze Code Coverage for All Tests. as below picture shown:
    69015-capture.png
    5.Run WinAppDriver.exe and run the Test units , then you can see test details in Test Explorer and Code Coverage Results.

    For more detailed steps and info, please refer to UI testing for Windows apps with WinAppDriver and Appium. By the way, if I misunderstand your question, please point out and give me more details to analyze.


    If the response is helpful, please click "Accept Answer" and upvote it.
    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.