This project is read-only.

Record and Playback Coded UI Testing

Best Practices

Use the following as a guide when creating your Record and Playback Tests:
  • First and For most, do not click and record an entire test into 1 method. This provides two things
    • Maintainablity: By chunking the test into multiple sub chunks, any changes that need to be made can be made without having to re-click the entire test.
    • Performance: By chunking the test into multiple sub chunks, it increases the speed of the test. In one example, chunking the test decreased test time by 45 seconds.
  • Do not interact with UI objects unless you have to. This means, don't open a drop down list and select an item from that list when it is possible to just type in what you want. This will increase speed because the test is not having to search through the grid that the drop down produces. Also, it is a general testing best practice to not interact with those type of controls.
  • Use the Coded UI Test Builder whenever possible.
  • Note: Do not modify the UIMap.designer.cs file directly. If you do this, the changes to the file will be overwritten.
  • Create your test as a sequence of recorded methods. For more information about how to record a method, see How to: Create a Coded UI Test found here:
  • Each recorded method should act on a single page, form, or dialog box. Create a new test method for each new page, form, or dialog box.
  • When you create a method, use a meaningful method name instead of the default name. A meaningful name helps identify the purpose of the method.
  • Create each assertion using the Coded UI Test Builder, which automatically adds an assertion method to the UIMap.Designer.cs file.
  • If the user interface (UI) changes, re-record the test methods, or the assertion methods, or re-record the affected sections of an existing test method.
  • Create a separate UIMap file for each module in your application under test. For more information, see Testing a Large Application with Multiple UI Maps.
  • In the application under test, use meaningful names when you create the UI controls. This gives more meaning and usability to the automatically generated control names.

What To Do If Your User Interface Changes

User interfaces frequently change during development. Here are some ways to reduce the effect of these changes:
  • Find the recorded method which references this control and use the Coded UI Test Builder to re-record the actions for this method. You can use the same name for the method to overwrite the existing actions.
  • If you need to rename a method, go to the .cs file and find the name of the method. From here you can select refactor and then rename.
  • If a control has an assertion that is no longer valid:
    • Delete the method that contains the assertion.
    • Remove the call to this method from the test method.
    • Add a new assertion by dragging the cross-hair button onto the UI control, open the UI map, and add the new assertion.

Last edited May 2, 2012 at 2:24 PM by agreff, version 3


No comments yet.