- Create a new MAUI application.
- Delete the standard App.xaml & App.xaml.cs
- Install Xunit.Runners.Maui nuget
- Create tests in this project or reference another project containing your tests.
- Create a MauiProgram like shown below - NOTE: It is not recommended you put any dependencies here
using Xunit.Runners.Maui;
namespace Sample
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp() => MauiApp
.CreateBuilder()
.ConfigureTests(new TestOptions
{
Assemblies =
{
typeof(MauiProgram).Assembly
}
})
.UseVisualRunner()
.Build();
}
}