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
<PackageReference Include="Xamarin.UITest.SpecFlowPlugin" Version="0.4.0" />
<PackageVersion Include="Xamarin.UITest.SpecFlowPlugin" Version="0.4.0" />
<PackageReference Include="Xamarin.UITest.SpecFlowPlugin" />
paket add Xamarin.UITest.SpecFlowPlugin --version 0.4.0
#r "nuget: Xamarin.UITest.SpecFlowPlugin, 0.4.0"
#:package Xamarin.UITest.SpecFlowPlugin@0.4.0
#addin nuget:?package=Xamarin.UITest.SpecFlowPlugin&version=0.4.0
#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
BaseTestFixtureclass that is used to create and startXamarin.UITest - Manually creating a partial test fixture with the appropriate
NUnit.TestFixtureAttributefor 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.TextFixtureAttributeso that you can then use them with the--include-categoryargument when running UI Tests.
Getting Started
The first thing to do is to install the SpecFlow extension for Visual Studio:
Create a new Xamarin.UITest Cross-Platform Test Project
Install the
SpecFlow.NUnitNuGet packageNow you can install the
Xamarin.UITest.SpecFlowPluginpackageCreate an
AppManagerclass at the root of your UI test project. This is going to be the bridge between the SpecFlow generated test fixture andXamarin.UITestAdd 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 }
Create a new feature file using the SpecFlow file template
Add a supported tag above the feature title. This is how
Xamarin.UITest.SpecFlowPluginwill pick up on which platforms to add as test fixture attributes. The following tags are supported:@uitestwill add bothPlatform.iOSandPlatform.Androidas test fixtures@uitest:ioswill addPlatform.iOSas a test fixture attribute@uitest:androidwill addPlatform.Androidas 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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net471 is compatible. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.1
- SpecFlow.CustomPlugin (>= 3.9.52)
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,697 | 2/28/2022 |
| 0.3.1-pre.0.1 | 245 | 2/25/2022 |
| 0.3.0 | 2,519 | 8/23/2021 |