In the last couple of posts we discussed about Coded UI Record and playback as well as UIMap in detail. In this post we will discuss about Assertions in Coded UI Test Builder. Using Assertion we can compare for the controls property for
Using the above comparator property we can compare for the controls using their compare value.
How to Add Assertion from Coded UI Test Builder
Adding assertion from Coded UI Test builder can be done simply by dragging the Cross hair and pointing to the intended control whose property needs to be asserted.
The Coded UI Test Builder screen looks something like this
So, using the Add Assertion button highlighted above, we can add assertion for the control. In our case, it’s Button 6.
Let’s add an assertion and verify if the control’s Friendly Name has Value “6” in it. To do that, just click the Friendly name property and click “Add Assertion” button, this will show you the assertion window as shown
Give some assertion failure message for the control, which will be displayed in the Test Explorer report if the test fails to find the specified control with the friendly name property.
Click “OK” and Generate the code to add the “AssertMethod1” in your Coded UI Test class of test method.
This will bring up an all new method in the Coded UI Test class as shown.
Here is the code for Assert method
As you can see from the above code, the message which we entered in the Add Assertion of Coded UI Test builder is displayed in the code.
Let’s see them in more detail in the video.
That’s all guys, thanks for reading and watching the post, please leave your comments in post and video.