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" />
paket add Xamarin.UITest.SpecFlowPlugin --version 0.4.0
#r "nuget: Xamarin.UITest.SpecFlowPlugin, 0.4.0"
// 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 startXamarin.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
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.NUnit
NuGet packageNow you can install the
Xamarin.UITest.SpecFlowPlugin
packageCreate an
AppManager
class at the root of your UI test project. This is going to be the bridge between the SpecFlow generated test fixture andXamarin.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 }
Create a new feature file using the SpecFlow file template
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 bothPlatform.iOS
andPlatform.Android
as test fixtures@uitest:ios
will addPlatform.iOS
as a test fixture attribute@uitest:android
will addPlatform.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 | 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,409 | 2/28/2022 |
0.3.1-pre.0.1 | 156 | 2/25/2022 |
0.3.0 | 2,396 | 8/23/2021 |