How to create Multiple UiTset files in a CodedUi Test Project?
The logically inter related blocks of modules within a System Under Test can be automated in a modularized block of code, in the following outlined manner. for our case we will just have a look at how we have create three different Uitest files.
The logically inter related blocks of modules within a System Under Test can be automated in a modularized block of code, in the following outlined manner. for our case we will just have a look at how we have create three different Uitest files.
The first UiTest file is AllLink.uitest file, which is actually a xml file, and its two components are namely , AllLink.cs and AllLink.designer.cs file. The designer file is non editable file which incorporates all the recorded set of scripts in it. The AllLink.cs file is again a partial class file which is used for more of data overriding and code globalisation along with reusability.
The second UiTest file is UsrIntrfc.uitest file, which is actually a xml file, and its two components are namely , UsrIntrfc.cs and UsrIntrfc.designer.cs file. The designer file is non editable file which incorporates all the recorded set of scripts in it. The UsrIntrfc.cs file is again a partial class file which is used for more of data overriding and code globalisation along with reusability.
The third UiTest file is MsgValidatn.uitest file, which is actually a xml file, and its two components are namely , MsgValidatn.cs and MsgValidatn.designer.cs file. The designer file is non editable file which incorporates all the recorded set of scripts in it. The MsgValidatn.cs file is again a partial class file which is used for more of data overriding and code globalisation along with reusability.
The approach for recording the various functions outlined as under has thus been classified into three specific categories, namely clicking the links, doing the functional event, and finally validating the final event of functionality being successful.
The AllLink uitest file is actually an xml file having the events related to clicking the links, similarly UsrIntrfc is the functional event, MsgValdtn is the validation checkpoint also called the assertion point in VSTS as termed in QTP automation.
At last we have one class file wherein , we will bring into use all three events from three uitest files and create a standard framework for automating with minimal rework effort.
Just have a look at the snapshot below to gain insights into how we arrange the multiple uitst files :
As outlined in the code below, we create an instance of all three uitest files, and utilize the features available as per the record time in them.
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;
using multipleuimaps.Uimaps.AllLinkClasses;
using multipleuimaps.UIAssertions.UsrIntrfcClasses;
using multipleuimaps.MsgValdtn.MsgValdtnClasses;
namespace multipleuimaps.Uimaps.AllLinkClasses
{
///
/// Summary description for CodedUITest1
///
[CodedUITest]
public class UploadValidation
{
public UploadValidation()
{
}
[TestMethod]
public void UploadValidationTestMethod1()
{
// To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
// For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
this.AllLink.ClkDocLink();
this.UsrIntrfc.FeatrUploadDoc();
this.MsgValdtn.ScsfulyUplodedDoc();
//this.AllLink.ClkDocMyHomeLnk();
//this.AllLink.ClkDocAdminLnk();
//this.AllLink.ClkDocAdminPrmsnLnk();
//this.AllLink.ClkDocAdminFltrLnk();
//this.AllLink.ClkDocAdminCreateRepLnk();
//this.AllLink.ClkDocAdminEditRepLnk();
}
#region Additional test attributes
// You can use the following additional attributes as you write your tests:
////Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
// // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
// // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
//}
////Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
// // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
// // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
//}
#endregion
///
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
private TestContext testContextInstance;
// References made to each of the three uitest files :
// AllLnk
// UsrIntrfc
//MsgValdtn
public multipleuimaps.MsgValdtn.MsgValdtnClasses.MsgValdtn MsgValdtn
{
get
{
if ((this.map2 == null))
{
this.map2 = new multipleuimaps.MsgValdtn.MsgValdtnClasses.MsgValdtn();
}
return this.map2;
}
}
private multipleuimaps.MsgValdtn.MsgValdtnClasses.MsgValdtn map2;
public AllLink AllLink
{
get
{
if ((this.map1 == null))
{
this.map1 = new AllLink();
}
return this.map1;
}
}
private AllLink map1;
public UsrIntrfc UsrIntrfc
{
get
{
if ((this.map == null))
{
this.map = new UsrIntrfc();
}
return this.map;
}
}
private UsrIntrfc map;
}
}
0 Comments