Wednesday, June 20, 2012

Best Practices for Coded UI Tests

  • Use the Coded UI Test Builder whenever possible.
  • Do not modify the UIMap.designer.cs file directly. If you do this, the changes to the file will be overwritten.
  • If you want to change some recorded code, add it in UIMap.cs and update the code and change the function name.
  • 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.
  • When possible, limit each recorded method to fewer than 10 actions. This modular approach makes it easier to replace a method if the UI changes.
  • 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. 
  • If you are creating assertions by coding with the API, create a method for each assertion in the part of the UIMap class that is in the UIMap.cs file. Call this method from your test method to execute the assertion.


1 comment: