Xamarin.UITest.SpecFlowPlugin 0.4.0

dotnet add package Xamarin.UITest.SpecFlowPlugin --version 0.4.0                
NuGet\Install-Package Xamarin.UITest.SpecFlowPlugin -Version 0.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xamarin.UITest.SpecFlowPlugin" Version="0.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xamarin.UITest.SpecFlowPlugin --version 0.4.0                
#r "nuget: Xamarin.UITest.SpecFlowPlugin, 0.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xamarin.UITest.SpecFlowPlugin as a Cake Addin
#addin nuget:?package=Xamarin.UITest.SpecFlowPlugin&version=0.4.0

// Install Xamarin.UITest.SpecFlowPlugin as a Cake Tool
#tool nuget:?package=Xamarin.UITest.SpecFlowPlugin&version=0.4.0                

Xamarin.UITest.SpecFlowPlugin

Unofficial SpecFlow plugin for Xamarin.UITest. I decided to create this plugin to remove the need for boiler-plate code, outlined here, when creating a new feature. This plugin will remove the need to:

  • Have a BaseTestFixture class that is used to create and start Xamarin.UITest
  • Manually creating a partial test fixture with the appropriate NUnit.TestFixtureAttribute for each desired platform

This is achieved by taking advantage of SpecFlow feature tags and replacing the default NUnit.TestFixtureAttribute on the generated test fixture.

NOTE: Each platform is also added as a category on the appropriate NUnit.TextFixtureAttribute so that you can then use them with the --include-category argument when running UI Tests.

Getting Started

  1. The first thing to do is to install the SpecFlow extension for Visual Studio:

  2. Create a new Xamarin.UITest Cross-Platform Test Project

  3. Install the SpecFlow.NUnit NuGet package

  4. Now you can install the Xamarin.UITest.SpecFlowPlugin package

  5. Create an AppManager class at the root of your UI test project. This is going to be the bridge between the SpecFlow generated test fixture and Xamarin.UITest

    • Add the following two methods:

      public static void Start(Xamarin.UITest.Platform platform)
      {
          // Configure Xamarin.UITest e.g.
          if(platform == Platform.Android)
              ConfigureApp.Android.StartApp()
          else
              ConfigureApp.iOS.StartApp();
      }
      
      public static void Shutdown()
      {
          // Run any shutdown logic required between scenarios
      }
      
  6. Create a new feature file using the SpecFlow file template

  7. Add a supported tag above the feature title. This is how Xamarin.UITest.SpecFlowPlugin will pick up on which platforms to add as test fixture attributes. The following tags are supported:

    • @uitest will add both Platform.iOS and Platform.Android as test fixtures
    • @uitest:ios will add Platform.iOS as a test fixture attribute
    • @uitest:android will add Platform.Android as a test fixture attribute
    • Any other tags will be treated as normal SpecFlow feature tags

Example output

@uitest
Feature: UITest category fixture generation 
    Simple calculator for adding two numbers

Scenario: Add two numbers
    ...

The above feature will produce the following output:

[NUnit.Framework.TestFixtureAttribute(Xamarin.UITest.Platform.iOS, Category="iOS")]
[NUnit.Framework.TestFixtureAttribute(Xamarin.UITest.Platform.Android, Category="Android")]
public partial class ExampleFeature
{
    ...

    [NUnit.Framework.SetUpAttribute()]
    public virtual void TestInitialize()
    {
        AppManager.Start(this._platform);
    }
    
    [NUnit.Framework.TearDownAttribute()]
    public virtual void TestTearDown()
    {
        testRunner.OnScenarioEnd();
        AppManager.Shutdown();
    }

    ...
}
Product Compatible and additional computed target framework versions.
.NET Framework net471 is compatible.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.4.0 3,409 2/28/2022
0.3.1-pre.0.1 156 2/25/2022
0.3.0 2,396 8/23/2021