Code Coverage Measurement for UWP Application

For a standard CSharp / UWP application, is there a good way to measure Unitest code coverage? It seems that Visual Studio tools are not used for UWP. My ultimate goal is to get an objective measurement of how thoroughly our testing is, and to monitor coverage regressions.

+5
source share
1 answer

I got code coverage to work in the following configuration using VS2015:

  • Create a portable class library (PCL) project.
  • In the project properties, reconfigure the project to .NETStandard1.4 (see the official compatibility matrix for choosing option v1.4).
  • Link to the PCL project from your UWP application.
  • For a test project, use xUnit and the .NET Core class library, setting it up as described in xUnit docs .

If you can minimize the amount of code in a UWP application project (for example, using the MVVM template), most of your tests will be against PCL. Since code coverage works with the installed .NET Standard standard library, your numbers will be fairly accurate even if you cannot measure the scope of the UWP application project itself.

(Of course, this is more practical for new applications than existing applications, as this requires a specific design).

0
source

Source: https://habr.com/ru/post/1245516/


All Articles