How to: Move a Method to UIMap to Enable Complete Customization Using the Coded UI Test Editor

By using the Coded UI Test Editor, you can open a coded UI test for viewing and editing. If you determine that a test method in your coded UI test has to have custom code added to it, you must move it to the UIMap file. If you do not move the method, your custom code will be overwritten each time the test is recompiled. Once you have moved the method, you can no longer edit it using the Coded UI Test Editor. You must add your custom code and maintain it using the Code Editor.

Opening a Coded UI Test in the Coded UI Test Editor

Follow these steps to open an existing coded UI test for editing in the Coded UI Test Editor.

To open a coded UI test in the Coded UI Test Editor

  1. In Solution Explorer, locate UIMap.uitest in your test project.

  2. Right-click UIMap.uitest and select Open.

    -or-

    Double-click UIMap.uitest.

    The coded UI test is displayed in the Coded UI Test Editor. You can now view and edit the coded UI test. For more information, see Editing Coded UI Tests Using the Coded UI Test Editor and How to: Edit a Coded UI Test Using the Coded UI Test Editor.

Move a Test Method to the UIMap File to Facilitate Customization

Follow these steps to move a test method in your coded UI tests to the UIMap file.

To move a test method to UIMap file

  1. In the UI Action pane, select the test method that you want to move to the UIMap.cs or UIMap.vb file to facilitate custom code functionality which won’t be overwritten when the test code is recompiled.

  2. Click the Move Code button on the Coded UI Test Editor toolbar.

    -or-

    Right-click the test method and click Move Code.

  3. A Microsoft Visual Studio dialog box is displayed. It warns you that the method will be moved from the UIMap.uitest file to the UIMap.cs or UIMap.vb file and that you will no longer be able to edit the method using the Coded UI Test Editor. Click Yes.

    The test method is removed from the UIMap.uitest file and no longer is displayed in the UI Actions pane. To can edit the moved test file, open the UIMap.cs or the UIMap.vb file from Solution Explorer.

    Tip

    To undo the move, select Undo from the Edit menu, or by pressing Ctrl+Z. However, you must then manually remove the code from the UIMap.cs or UIMap.vb file.

  4. On the Visual Studio toolbar, click Save.

    The updates to the test method are saved in the UIMap.Designer file.

See Also

Tasks

How to: Split a Method to Better Modularize Your Test Code Using the Coded UI Test Editor

Other Resources

Editing Coded UI Tests Using the Coded UI Test Editor