Setup Unit Testing (xUnit) for Xamarin.Forms

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

Launch Visual Studio. Select File, New, Project...

Select C#, Cross-Platform, Blank Xaml App (Xamarin.Forms Portable) template and select OK.

Select the Target and Minimum version and select OK.

The template has references to a older version of Xamarin.Forms and the .NET Core. Let's go ahead and update to the latest. Select the Updates tab and then check Microsoft.NETCore.UniversalWindowsPlatform and Xamarin.Forms.

Select OK.

Select I Accept.

The NuGet package manager will update the selected specified packages. Press the re-launch to relaunch Visual Studio.

Select the Browse tab and enter xunit in the search box. Select xunit.runner.devices and press the install button.

Press OK

Select the Browse tab and enter xunit in the search box. Select xunit.runner.devices and press the install button.

Press OK.

Select the Browse tab and enter xunit in the search box. Select xunit.runner.devices and press the install button.

Press OK.

Select the Browse tab and enter xunit in the search box. Select xunit.runner.devices and press the install button.

Press OK.

Select the Browse tab and enter xunit in the search box. Select xunit.runner.devices and press the install button.

Press OK.

Select the Browse tab and enter xunit in the search box. Select xunit and press the install button.

Press OK.

The source code is located on my GitHub site (wpbest/xUnitXamarinFormsTestRunner): https://github.com/wpbest/xUnitXamarinFormsTestRunner

No Comments

Add a Comment

As it will appear on the website

Not displayed

Your website