Getting Started with

Universal Windows Apps (UWP) with the Devices Runner

In this article, we will demonstrate getting started with for UWP, showing you how to write and run your first set of unit tests.

  1. File -> New Project and create a Blank UWP project:

  2. Add the xunit.runner.devices package. If you want unit tests in this project, also add xunit:

  3. Replace App.xaml and App.xaml.cs with the following (using your namespace in x:Class):
    • App.xaml

    • App.xaml.cs
      using System.Reflection;
      using Xunit.Runners.UI;
      namespace UwpTestRunner
          sealed partial class App : RunnerApplication
              protected override void OnInitializeRunner()
                  // tests can be inside the main assembly
                  // otherwise you need to ensure that the test assemblies will
                  // become part of the app bundle
                  // AddTestAssembly(typeof(PortableTests).GetTypeInfo().Assembly);

  4. Delete MainPage.xaml and MainPage.xaml.cs:

  5. Add your unit tests:

  6. (optional) If your tests are in other assemblies, add a project reference and modify the App.xaml.cs to include the assembly containing your tests
  7. (optional) Add a xunit.runner.json file as Content to specify runner configuration
Copyright © .NET Foundation. Contributions welcomed at