What is Coded UI Test?

Coded UI Tests are automated tests that drive your application through its user interface. These tests include functional testing of the UI controls. They let you verify that the whole application, including its user interface, is functioning correctly.

Coded UI Features

  • Functional Testing
  • Generate code in C#
  • Intent aware recording and resilient playback
  • Integrated with ALM story
    • Build, deploy & test in lab or as part of build
    • Local, remote runs, data collection

Creating Coded UI Test

Coded UI Test can be created the following ways:

  • Fast Forward Automation using MTM
  • Generating your Coded UI form existing recording (Convert the recorded actions from a manual test)
  • Generating a new Coded UI Test from scratch using Coded UI Test Builder
  • Writing your own Coded UI (Advance option)

Test Automation Pyramid & Visual Studio

codedui

Creating Coded UI Tests

 1. Create a Coded UI Test project.

  • Open Visual Studio
  • Choose File < New < Project
  • Use C# Template go to Test and choose Coded UI Test Project

codedui

2. Add a coded UI test file

If you just created a Coded UI project, the first CUIT file is added automatically

codedui

In the Generate Code for Coded UI Test dialog box, choose Record actions, edit UI map or add assertions.

codedui

The Coded UI Test Builder appears and Visual Studio is minimized, choose Generate Code

coded ui

Generated Coded UI Files

CodedUITest1.cs: Contains the coded UI test class, test methods.

UIMap.uitest: This is an xml file that should only be edited by double clicking on this file and using the UI Map Editor

UIMap.cs: This file contains custom code and may be hand edited. It will be blank when it is initially created.

UIMap.Designer.cs: This file contains generated code. Do not edit this file as you changes will be overwritten any time visual studio regenerates this file.

Coded UI Test Example

CodedUITest1.cs

UIMap.uitest

Sample code that shows how to find objects

 

 [/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]