Coded UI Test Extension

Coded UI Test Extension

The Coded UI Test Extension for DevExpress WinForms controls is an extension of Microsoft Coded UI Tests (CUIT), which allows you to create automated tests of the user interface. Using these tests, you can perform functional testing of the UI and validation of UI controls. As a UI tester, you perform an action on a control’s UI and then check a control’s state or value. If this control’s state or value is invalid, the test fails. With Microsoft CUIT, you can record a test, add an assertion and then repeat testing automatically later at any time. More information on Microsoft Coded UI Tests can be found in MSDN.

The Coded UI Test Extension for DevExpress WinForms controls is an extension to Microsoft CUIT tailored to facilitate UI testing on DevExpress WinForms controls.

There are four levels of CUIT support. For majority of DevExpress WinForms controls, all four levels are supported, making the code generated by CUIT more readable and maintainable. See Supported Controls and Actions to learn more.

The following topics provide more information.

  • Getting Started
  • Supported Controls and Actions
  • Prerequisites
  • Known Issues
Copyright(c) 1998-2023 Developer Express Inc. All rights reserved.
Send Feedback on this topic to DevExpress.


Getting Started

Getting Started

This tutorial shows how to create an automated test using Microsoft Coded UI Test for an application containing an XtraGrid control.

  1. Start Microsoft Visual Studio Ultimate or Premium with administrative permissions.
  2. Create a new test Coded UI Test Project project.

  3. Select the first option in the Generate Code for Coded UI Test dialog and click OK.

  4. When this dialog is closed, a Coded UI Test Builder is displayed, helping you record tests and create assertions.

  5. Run the application on which you will be performing UI testing.

  6. In the test, you will record changes to the grid control’s cell value. Click the Record button in the Coded UI Test Builder, and after recording starts, modify the grid control’s cell value. When finished, click the Pause button.

  7. Click the Generate Code button in the Coded UI Test Builder to generate a test method. The generated method will be as follows.

    • C#
    public void RecordedMethod1()
{
    #region Variable Declarations
    DXTestControl uIGridControl1Table = this.UIXtraGridFeaturesDemoWindow.UIPanelControl1Client.UIGcContainerClient.UITableViewCustom.UIGridControl1Table;
    DXTestControl uIGridControl1LookUpEdEdit = this.UIXtraGridFeaturesDemoWindow.UIPanelControl1Client.UIGcContainerClient.UITableViewCustom.UIGridControl1Table.UIGridControl1LookUpEdEdit;
    #endregion

    // Type 'SetFocusedCell [View]gridView1[Row]1[Column]gridColumn2' in the 'gridControl1' table
    uIGridControl1Table.Focus = this.RecordedMethod1Params.UIGridControl1TableFocus;

    // Type 'System.Int32' in the 'gridControl1LookUpEdit[View]gridView1[Row]1[Column]gridColumn2' text box
    uIGridControl1LookUpEdEdit.ValueType = this.RecordedMethod1Params.UIGridControl1LookUpEdEditValueType;

    // Type '33 AutoSearchText0' in the 'gridControl1LookUpEdit[View]gridView1[Row]1[Column]gridColumn2' text box
    uIGridControl1LookUpEdEdit.EditValue = this.RecordedMethod1Params.UIGridControl1LookUpEdEditEditValue;
}

    As you can see, recorded actions are aggregated into corresponding method calls. The first statement below the #region block focuses the cell that belongs to the second row and second column. If you check the RecordedMethod1Params.UIGridControl1TableFocus variable, it will be defined as follows.

    • C#
    public string UIGridControl1TableFocus = "SetFocusedCell [View]gridView1[Row]1[Column]gridColumn2";

    The other two statements in the RecordedMethod1 method change the in-place editor’s value.

  8. Next, you will create an assertion that will check the modified cell’s value. To create an assertion, click the crosshair button in the Coded UI Test Builder and drag it to the modified cell. After releasing the mouse button, an Add Assertions window is displayed, allowing you to add assertions. In the following video, two assertions are added for the in-place editor’s Text and EditValue properties.

  9. Click the Generate Code button in the Coded UI Test Builder to generate an assertion method.

    • C#
    public void AssertMethod1()
{
    #region Variable Declarations
    DXTestControl uIGridControl1LookUpEdEdit = this.UIXtraGridFeaturesDemoWindow.UIPanelControl1Client.UIGcContainerClient.UITableViewCustom.UIGridControl1Table.UIGridControl1LookUpEdEdit;
    #endregion

    // Verify that the 'gridControl1LookUpEdit[View]gridView1[Row]1[Column]gridColumn2' text box's 'Text' property equals 'Geitost'
    Assert.AreEqual(this.AssertMethod1ExpectedValues.UIGridControl1LookUpEdEditText, uIGridControl1LookUpEdEdit.GetProperty(DXTestControl.PropertyNames.Text).ToString());

    // Verify that the 'gridControl1LookUpEdit[View]gridView1[Row]1[Column]gridColumn2' text box's 'EditValue' property equals '33'
    Assert.AreEqual(this.AssertMethod1ExpectedValues.UIGridControl1LookUpEdEditEditValue, uIGridControl1LookUpEdEdit.GetProperty(DXTestControl.PropertyNames.EditValue).ToString());
}

  10. Next, record a new action that groups data by a column. Again, click the Record button in the Coded UI Test Builder and group the grid by a column, and then click the Pause button.

  11. Click the Generate Code button in the Coded UI Test Builder to generate a new test method.

    • C#
    public void RecordedMethod2()
{
    #region Variable Declarations
    DXTestControl uIGridControl1Table = this.UIXtraGridFeaturesDemoWindow.UIPanelControl1Client.UIGcContainerClient.UITableViewCustom.UIGridControl1Table;
    #endregion

    // Type '[View]gridView1[Column]gridColumn2[VisibleIndex]1[GroupIndex]0' in the 'gridControl1' table
    uIGridControl1Table.ColumnPosition = this.RecordedMethod2Params.UIGridControl1TableColumnPosition;
}

    The RecordedMethod2Params.UIGridControl1TableColumnPosition variable is defined as follows.

    • C#
    public string UIGridControl1TableColumnPosition = "[View]gridView1[Column]gridColumn2[VisibleIndex]1[GroupIndex]0";

    This ensures that data is grouped by the corresponding column.

  12. Create an assertion to check the column’s group index. Drag the crosshair onto the group column and add an assertion for the column’s GroupIndex property.

  13. Generate the code for the assertion.

    • C#
    public void AssertMethod2()
{
    #region Variable Declarations
    DXTestControl uIGridControl1GridContColumnHeader = this.UIXtraGridFeaturesDemoWindow.UIPanelControl1Client.UIGcContainerClient.UITableViewCustom.UIGridControl1Table.UIGridControl1GridContColumnHeader;
    #endregion

    // Verify that the 'gridControl1GridControlGroupPanelColumn[View]gridView1[Column]gridColumn2' column header's 'GroupIndex' property equals '0'
    Assert.AreEqual(this.AssertMethod2ExpectedValues.UIGridControl1GridContColumnHeaderGroupIndex, uIGridControl1GridContColumnHeader.GetProperty("GroupIndex").ToString());
}

  14. After all tests and assertions are created, you can run tests.

    Before running tests, ensure that the test application is launched and the initial states of controls are the same as those at the beginning of the test recording.

Copyright(c) 1998-2023 Developer Express Inc. All rights reserved.
Send Feedback on this topic to DevExpress.


Supported Controls and Actions

Supported Controls and Actions

There are four levels of Microsoft Coded UI Test (CUIT) support:

  1. Basic Record and Playback - Recorder identifies elements involved in an action via Microsoft Active Accessibility (MSAA).
  2. Rich Property Validation - A set of properties are defined for each DevExpress control on which a user can add assertions.
  3. Code Generation - Dedicated classes are generated for involved objects, making test methods more readable and maintainable.
  4. Aggregated Actions - An action is recorded using aggregated methods, not using low-level methods (such as mouse clicks).

All DevExpress WinForms controls provide support for CUIT level 1. Products covered in the following table also maintain levels 2 and 3 of CUIT support. Level 4 of CUIT support is maintained by the majority of the controls listed in this table. Corresponding aggregated actions for these controls are shown in the last column.

Library | Controls and Components | Supported Aggregated Actions (Level 4 of CUIT Support)
XtraEditors | Editors and controls | All mouse and keyboard actions that change the editor’s value, selected item, text selection, etc.
XtraGrid | GridControl - GridView, BandedGridView, AdvBandedGridView | Changing the size, position and visibility of columns. Data grouping and filtering, including filtering via the embedded Filter Editor. Focusing cells and changing their values.
 | GridLookUpEdit and SearchLookUpEdit | Changing the editor’s value and auto-search text.
XtraBars | BarManager | Docking bars; clicking baritems; editing bar item values.
 | RibbonControl | Clicking items; item value editing.
 | Document Manager | Docking forms and dock panels.
 | Dock Manager | Docking dock panels.
 | XtraTabbedMdiManager | Dragging tabs
 | Alert Control | -
XtraNavBar | NavBarControl | Clicking items; dragging a splitter in the Navigation Pane.
XtraPivotGrid | Pivot Grid Control | Dragging field headers; resizing field values; cell selection and editing.
XtraPrinting | Print Preview | Dragging margins.
XtraReports | Print Preview | Dragging margins.
XtraTreeList | TreeList | Changing the size, position and visibility of columns. Changing row size. Focusing cells and changing their values. Expanding and checking nodes. Data filtering, including filtering via the embedded Filter Editor.
XtraVerticalGrid | VGridControl and PropertyGridControl | Dragging rows. Focusing cells and changing their values. Changing the size of columns, rows, multi-editor cells and bands. Expanding and collapsing rows.
XtraLayoutControl | LayoutControl, DataLayoutControl | -

Note

For actions not listed in this table, level 1 of CUIT support is maintained. These actions will be recorded by using mouse and keyboard events.

Copyright(c) 1998-2023 Developer Express Inc. All rights reserved.
Send Feedback on this topic to DevExpress.


Prerequisites

Prerequisites

The Coded UI Test Extension for DevExpress WinForms controls is licensed under the DevExpress Universal Subscription.

The following table shows the Visual Studio editions supported by different versions of the CUIT Extension for DevExpress WinForms controls.

DevExpress Version | Visual Studio 2022 | Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015 | Visual Studio 2013 | Visual Studio 2012 | Visual Studio 2010
v22.1+ | yes | yes | yes | yes | yes | yes | no
v21.2 | yes (v21.2.4+) | yes | yes | yes | yes | yes | no
v21.1 | yes (v21.1.7+) | yes | yes | yes | yes | yes | no
v19.1 - v19.2 | no | yes | yes | yes | yes | yes | no
v18.2 | no | yes (v18.2.4+) | yes | yes | yes | yes | no
v18.1 | no | yes (v18.1.8+) | yes | yes | yes | yes | yes
v17.1 - v17.2 | no | no | yes | yes | yes | yes | yes
v16.2 | no | no | yes (v16.2.5+) | yes | yes | yes | yes
v16.1 | no | no | yes (v16.1.10+) | yes | yes | yes | yes
v15.2 | no | no | yes (v15.2.15+) | yes | yes | yes | yes
v15.1 | no | no | no | yes | yes | yes | yes
v14.2 | no | no | no | yes (v14.2.7+) | yes | yes | yes
v14.1 | no | no | no | yes (v14.1.11+) | yes | yes | yes
v13.2 | no | no | no | no | yes | yes | yes
v13.1 | no | no | no | no | yes (v13.1.7+) | yes | yes
v12.2 | no | no | no | no | yes (v12.2.9+) | yes | yes
v12.1 | no | no | no | no | no | yes (v12.1.5+) | yes

The CUIT Extension for DevExpress WinForms controls allows you to create and run tests using other tools from Microsoft: Visual Studio Test Professional, Test Manager and Test Agent. Supported versions of these tools match those of the Visual Studio editions in the table above.

Copyright(c) 1998-2023 Developer Express Inc. All rights reserved.
Send Feedback on this topic to DevExpress.


Known Issues

Known Issues

This topic lists issues you may encounter while using the Coded UI Test Extension for DevExpress WinForms controls:

  • Controls not listed in the Supported Controls and Actions topic, provide the level 1 of CUIT support via Microsoft Active Accessibility (MSAA).
  • Assertions can be added for the most common control elements and their properties. If you need to add an assertion on a control’s element or property that is not currently available, please contact our support service, so we can add new functionality.
  • Level 4 of CUIT support requires an application to be highly responsive. When recording a test on a computer with a slow configuration, perform actions slowly so that they are properly registered by CUIT.
Copyright(c) 1998-2023 Developer Express Inc. All rights reserved.
Send Feedback on this topic to DevExpress.