Assertions in Coded UI
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.
Assertions are added with the help of Coded UI Test Builder. Open Test Builder, Click on crosshairs icon 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.
Select the UI control, properties of UI control will be displayed on right hand side.
Select property and choose Add Assertion.
In dialog box select Comparator, provide Comparison Value and Message on Assertion Failure.
Provide Method name, description for Assertions and generate code. The generated code method will be displayed in Visual Studio Editor.
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.