Share via


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

By using the Coded UI Test Editor, you can open a coded UI test for viewing and editing. One of the editing capabilities available in the Coded UI Test Editor is splitting your test methods. Splitting your test methods can be useful because it lets you modularize the UI actions.

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.

Split a Test Method into Two Separate Methods

Follow these steps to split a test method in your coded UI tests.

Splt a test methodTwo test methods

To split a test method

  1. In the UI Action pane, expand the test method that you want to split into two separate methods.

  2. In the test method, select the UI action where you want the new test method to begin.

    Click the Split into a new method button on the Coded UI Test Editor toolbar.

    -or-

    Right-click the UI action and then click Split into a new method.

  3. A Microsoft Visual Studio dialog box is displayed. It warns you that you must modify any code that calls the existing method to also call the new method you are about to create. Click Yes.

    The new test method appears in the UI Actions pane. The test method contains the UI actions where you specified the split.

    Tip

    To undo the split, select Undo from the Edit menu, or press Ctrl+Z.

  4. (Optional) You can rename the new method. Select it in the UI Actions pane and click the Rename button in the Coded UI Test Editor toolbar.

    -or-

    Right-click the new test method and select Rename.

    A Microsoft Visual Studio dialog box is displayed. It warns you that you must modify any code that references the method. Click Yes.

  5. On the Visual Studio toolbar, click Save.

    The new method is saved in the UIMap.Designer file.

See Also

Tasks

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

Other Resources

Editing Coded UI Tests Using the Coded UI Test Editor