Canarys | IT Services

Blogs

Assertions in Coded UI

Share

Let us discuss how to add assertions in coded UI.

Assertions are checkpoints/benchmarks to UI controls and are used to verify the expected results of UI controls in Coded UI testing.

Following are some of the assertions that are available in Coded UI.

  •     AreEqual
  •     AreNotEqual
  •     Contains
  •     Matches
  •     DoesNotMatch
  •     StartsWith
  •     EndsWith
  •     IsNull
  •     IsNotNull

Assertions are added with the help of Coded UI Test Builder. Open Test Builder, Click on crosshairs icon 1 or drag the crosshair cursor onto UI control in application which results to be verified.

When clicked on crosshair icon (third button), assertion dialog box will be opened. Click on the left arrow << (Show UI Control Map) to navigate through UI controls.

2

Select the UI control, properties of UI control will be displayed on right hand side.

3

Select property and choose Add Assertion.

4

In dialog box select Comparator, provide Comparison Value and Message on Assertion Failure.

5

Provide Method name, description for Assertions and generate code. The generated code method will be displayed in Visual Studio Editor.

6

Build the code once again and Run Tests to verify assertion results.

If the Comparison value doesn’t match with UI control value, assertion failure message will be displayed as test result.

Happy Testing

Leave a Reply

Your email address will not be published. Required fields are marked *

Reach Us

With Canarys,
Let’s Plan. Grow. Strive. Succeed.