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

21
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

Upload: others

Post on 29-Mar-2020

49 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 2: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 3: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

Objective

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

Page 4: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 5: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 6: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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)

Page 7: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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.

Page 8: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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)

Page 9: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

Adding Extra Recordings and Asserts to the UIMaps

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

Page 10: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 11: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 12: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 13: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

Another Option

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

Page 14: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 16: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

TFS API Example – Get Results of Test Run

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

Page 17: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

An Easy to Use Tool

• Written in C# using WPF

Page 18: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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

Page 19: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

Visual Mapping

Page 20: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

End Result

Page 21: Coded UI – Managing Multiple UI Maps and Generating Test …files.meetup.com/3352572/Coded UI - Managing Multiple UI Maps and Generating Test Steps...• Rename Test Project (if

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