coded ui – managing multiple ui maps and generating test …files.meetup.com/3352572/coded ui -...

Post on 29-Mar-2020

50 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Coded UI – Managing Multiple UI Maps and Generating Test Steps

Extra Effort Involved in Putting Readable Test Steps from a Coded UI Automated

Recorded Test into Test Case Work Items

Problem: Organization of Readable Test Steps in Coded UI Files

• By default Coded UI puts all its “test steps” and asserts (expected results) into one big UIMap.Designer map file

• This includes all of comments of what steps are being performed for each test case method in readable form

Objective

• We want to organize these comments in a better way so when we want to get at them they are already correctly ordered

Solution: Have a Separate UI Map for each Coded UI Test

• Making a UI Map for each test will allow us to have a separate file of readable test steps for each test

• Helps keep everything more organized and separated

Script Getting the Comments

• With this we will be able to use a script that we could run against each UI Map file that will take out the comments and put them into a separate file for each file

Set Up Multiple UI Maps • Create a New Test Project • Delete UnitTest file generated • Rename Test Project (if needed) to something more useful than the Solution name • Create a Folder “UI Maps” • Add a Coded UI test file to project • Import the recorded test case from Test Manager into the Coded UI file • Move UIMap.uitest to UI Maps folder • Rename UIMap.uitest to the same name as the imported Test Case (i.e. One Line of Text)

Make UI Map Code Unique • Rename the UIMap class name to the same name as the Test Case but without spaces (i.e. OneLineofText) • Rename the namespace in the UIMap so that this is appended: .UIMap.[same CodedUI file name]Classes (i.e. Notepad.Automation.UIMaps.OneLineofTextClasses), where Notepad.Automation is the namespace of the project file.

Update the Coded UI Test’s Code to Point to the Changed UI Map

• Section below TextContext will not work because it tries to access just regular UIMap instead of the customized moved UIMap, so we need to update it to point to correct UIMap(s)

• Update the section below TextContext so that it uses the correct reference to the UIMap class

• Rename the Property definition to reference the “Class” in your custom UIMap (i.e. Notepad.Automation.UIMaps.OneLineofTextClasses.OneLineofText)

• Rename instances of “map” to [Name of the UIMap]Map (i.e. OneLineofTextMap)

Adding Extra Recordings and Asserts to the UIMaps

• If needed you can Edit a UIMap with the Coded UI Test Builder

What this accomplishes

• We now have a UI Map for each Test Case and having this organization will allow us to use a script to take the test step comments out of each UI Map and put them into separate files for each corresponding Test Case

Make the Script Smarter

• From here we could create a script that is smart enough to get all of names of the Test Cases and get the comments for each Test Case name, since their UI Maps now contain the same name

Problem: Time Consuming

• Fully automating every single Test Case you create in Test Manager can be very time consuming, especially for a lot of Test Cases

Another Option

• Instead you could use the recorded actions as your Test Steps from when you recorded your Test Cases in Test Manager

Solution: Create a Tool

• This requires a little extra effort to programmatically connect to TFS and get the proper TCXXXX_ActionLog.txt attachment from the Test Results

TFS API Example – Get Results of Test Run

• Instead: Iterate over the test result attachments to get the ones you want

An Easy to Use Tool

• Written in C# using WPF

Parameters Explanation

• Team Project Collection URL – URL used to connect to TFS (i.e.

tfs.mytfs.com:8080/tfs/collection

• Team Project – Project in TFS where Test Plan resides (i.e. My

Testing Project)

• Test Plan ID – ID number used by Test Manager that is assigned

to your Test Plan where your Test Cases are at

Visual Mapping

End Result

Further Investigation

• Extend the tool to also get Assert comments from UI Maps – This requires making the tool smart enough to

compare the Test Case names/titles in Test Manager to the UI Map names we used when we created our UI Maps

top related