This guide explains how to use the QualityMate with a test framework other than MSTest. You can follow this guide step by step or download and run the complete sample:
Creating the sample step by step
What does this guide cover?
Creation of a test solution that integrates QualityMate with a test framework of selection.
The recommended solution structure that you should use.
The QualityMate dependencies that you need.
A simple Page Object and Test Case to run on a web browser.
Before this guide
The steps used on this guide uses NUnit as a reference, however, these steps should work with any other preferred test framework like XUnit with minor changes.
This guide assumes that you will use the following application asset:
Set up your application environment
To create our first Application with QualityMate, we're going to:
Create a test C# project using the .Net Framework version 4.6.1 or higher and name it HelloWorldNUnit. If you're working on Visual Studio, information on how to do this can be found here.
Create a TestCases folder inside the project folder.
On the TestCases folder, create a new C# file with the name TC_HelloWorld.cs.
Create an Assets folder inside the project folder.
Set the assets files to copy to the output directory and add the required NuGet dependencies. To do this, open your project file (HelloWorldNUnit.csproj) and add the following lines:
<ItemGroup> <PackageReferenceInclude="Mobilize.QualityMate.UiPlayer"Version="7.*" /> <PackageReferenceInclude="NUnit"Version="3.13.2" /> <PackageReferenceInclude="NUnit3TestAdapter"Version="4.1.0" /><!--This package might require an update to match the chrome version installed on the machine.--> <PackageReferenceInclude="Selenium.WebDriver.ChromeDriver"Version="95.0.4638.5401" /></ItemGroup><ItemGroup> <NoneUpdate="Assets\*"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None></ItemGroup>
The project folder structure should look like the following example:
The project file HelloWorldNUnit.csproj content should look like the following example:
<ProjectSdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net461</TargetFramework> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> </PropertyGroup> <ItemGroup> <PackageReferenceInclude="Mobilize.QualityMate.UiPlayer"Version="7.*" /> <PackageReferenceInclude="NUnit"Version="3.13.2" /> <PackageReferenceInclude="NUnit3TestAdapter"Version="4.1.0" /><!--This package might require an update to match the chrome version installed on the machine.--> <PackageReferenceInclude="Selenium.WebDriver.ChromeDriver"Version="95.0.4638.5401" /> </ItemGroup> <ItemGroup> <NoneUpdate="assets\**\*.*"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup></Project>
Describe the UI of the target application
It's time to create our first Page Object; we're going to do the following:
Create a folder named PageObjects inside the project folder.
Create a Form1.cs file inside the PageObjets folder.
Create the properties that represents each UI controls that we are going to use on Form1 class
// Describes a TextBox control presented on the asset Application.public ITextBox textBox1 { get; set; }// Describes a Button control presented on the asset Application.public IButton button1 { get; set; }// Describes a Label control presented on the asset Application.public ILabel label1 { get; set; }
Create a method ChangeTextBox1Text(string) on the Form1.cs to handle the text change behavior.
/// <summary>/// Changes the <seecref="textBox1"/> text to the specified <paramrefname="newText"/>./// </summary>publicvoidChangeTextBox1Text(string newText){textBox1.Text= newText;button1.Click();}
The Form1.csfile content should look like the following example:
usingMobilize.QualityMate.Automation.Entities;usingMobilize.QualityMate.ControlInterfaces;publicclassForm1:PageObject{ // Describes a TextBox control presented on the asset Application.publicITextBox textBox1 { get; set; } // Describes a Button control presented on the asset Application.publicIButton button1 { get; set; } // Describes a Label control presented on the asset Application.publicILabel label1 { get; set; } /// <summary> /// Changes the <seecref="textBox1"/> text to the specified <paramrefname="newText"/>. /// </summary>publicvoidChangeTextBox1Text(string newText) {textBox1.Text= newText;button1.Click(); }}
The fields specified in the code snip above represent each UI control of the assets' application.
Create a new UI script
Once we have a PageObject, we can create a new QualityMate script on the TC_HelloWorld.cs file
Create the method HelloWorldScript(UiExecutionController controller), this method will let us interact with the UI using the controller with the next code: