• Home
  • Testing
  • SAP
  • Web
  • Must Learn!
  • Big Data
  • Live Projects
  • AI
  • Blog

A typical software automation Testing requires automation tool like Selenium and QTP. Coded UI is similar to these tools and can be particularly useful for functional tests.

Coded UI Test ( CUIT) uses Visual Studio IDE to write scripts, as the recording can be done using Visual Studio.

In this tutorial, you will learn-

What is Coded UI Test (CUIT)?

CUIT are automated tests that drive your application through its user interface (UI). Hence, the name coded UI tests (CUITs). These tests involve functional testing of the UI controls. It checks the functionality of the whole application including the user interface.

Coded UI Test (CUIT)

Coded UI Test Features

Coded UI features include

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

Coded UI Test (CUIT) Supported Technologies

With coded UI, an application which has UI (User Interface) can be easily tested. The application can be either window based or web based.

Coded UI supports technologies like

  • Window based desktop applications
  • Web Services (SOAP, ASPX, etc.)
  • Window phone applications
  • WPF (Windows Presentation Foundation)
  • Web applications (HTML, Silverlight, HTML5)

Why use coded UI for test automation

The reason why coded UI for test automation is preferred

  • Developers and Software Testers can collaborate effectively using the same tools/language.
  • It supports both webs as well as Windows projects.
  • The element identification mechanism is a great feature in Coded UI. Also, it supports synchronization
  • The Playback Engine supports features such as 'WaitForControlExist' , 'WaitForReadyLevel', etc
  • With the help of 'Tests Agents,' automation tests can be run on remote machines
  • Automation teams can develop sophisticated tests, using coded UI with a layered framework
  • Software testers can capture exceptions and record the result effectively utilizing log4net.dll
  • Coded UI tool supports descriptive programming. It allows software testers to automate scenarios based on object properties
  • It supports AJAX controls.

How to create coded UI tests(CUIT)

To create coded UI tests you can do it in following ways.

  • Generating from an Existing Action Recording ( converting from manual test recording)
  • Creating a new coded UI test from scratch
  • Writing code from scratch

Contents of a Coded UI Test

When you create a coded UI test, the coded UI test builder creates a Map. This includes UI under test, test methods, parameters, assertions, etc. For each test, it also creates a class file.

File Content Editable
UIMap.Designer.cs Declaration section UIMap Class Methods Properties No
UIMap.cs UIMap class (partial) Yes
CodedUITest1.cs CodeUITest1 class Methods Properties Yes
UIMap.uitest The XML map of the UI for the test. It is edited only through UI Map editor No
  1. UIMap.Designer.cs : The designer contains the code view of the UIMap. It is generated when a tester records some UI interaction or when some objects are added manually to the UIMap.
  2. UIMap.cs: Any modification or customization done to the UIMap is stored in this file. Initially, this file will be blank and can be populated later on. If modifications are directly madeto the UIMap.designer.cs file, make sure it is not recorded otherwise all changes will be lost.
  • CodedUITest1.cs: This file contains coded UI test class, test methods, assertion invocation and method invocation. All assertion and methods are by default invoked from this file.
  • UIMap.uitest: It is an XML representation of the UIMap class. It includes windows, controls, properties, methods, actions and assertions. It is edited only through UI Map editor

How to perform coded UI test

Coded UI has two different ways to conduct a test for your application.

  1. Coded UI Record and Playback or
  2. Coded UI Hand coding

You have to follow the following step to perform coded UI test,

  1. Create a coded UI test project
  2. Add a coded UI test file
  3. Record a sequence of actions
  4. Verify the values in UI fields such as text boxes
  5. View the generated test code
  6. Add more actions and assertions
  7. Edit the details of the test activities and the assertions
  8. Run the test

 

Best practices for Coded UI Test (CUIT)

Here are some best practices for a coded UI test,

  • Use the Coded UI Test Builder whenever possible
  • Try not to modify the UIMap.designer.cs file directly. Otherwise, the changes you made to the file will be overwritten
  • Create your test as a sequence of recorded methods
  • Each recorded method should act on a single page, form or dialog box. Also, create a new test method for each new form, page or dialog box
  • When you create a method, instead of the default name use a meaningful method name. A meaningful name helps identify the purpose of the method
  • If possible, limit each recorded method to less than 10 actions. This approach makes it easier to replace a method if the UI changes.
  • To create assertion use coded UI test builder. It automatically adds an assertion method to the UIMap.Designer.cs file.
  • Re-record the test methods/ assertion methods, if the user interfaces changes or re-records the affected sections of an existing test method.
  • If you are directly coding with the API, use the methods and properties in the classes created in the UIMap.Designer.cs file. These classes will make your work more reliable and easier, and will help you to be more productive.

Comparison of coded UI test Vs. Selenium vs. QTP

Below is the comparison table of coded UI test with other automation tools.

  • Selenium does not support any WPF as well as Windows applications
  • Visual Studio Coded UI supports the Window store application testing as well as Window Phone application testing. No other tools support this.
  • Test complete does support Window Application but requires a plugin to be installed.

Coded UI Test (CUIT)

Summary:

  • Automated tests that drive your application through its user interface (UI) are known as coded UI tests (CUITs).
  • Coded UI supports technologies like Web Services, Window phone applications, Web applications, etc.
  • Coded UI allows developers and Software testers to collaborate effectively using the same tools/language
  • Contents or a file created while using coded UI includes
    • UIMap.Designer.cs
    • UIMap.cs
    • CodedUITest1.cs
    • UIMap.uitest

 

YOU MIGHT LIKE: