Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Automated UI Testing in .NET

Automated UI Testing in .NET


Recently DevExpress announced that they are the first third-party control vendor to achieve full support for Coded UI. So we decided to take this opportunity to talk about Coded UI and how it can play a role in building a comprehensive automated test suite.

At the core of any Coded UI test is the UI Map. The UI Map begins life as a recording of user actions (e.g. mouse clicks) much like how you would create a macro in a word processor. In addition to the steps themselves, the recording identifies user controls that you can interact with later. Here is an example of one such definition:

Note the “search properties” dialog. This is what the test runner uses to find the control on the screen. There are lots of different aspects you can use to search for, as shown below.

As the user interface evolves and tests are broken, you may find yourself modifying the search properties by hand. One way to reduce the need for this is to give key controls a Name or an AutomationId. The AutomationId was primarily created for accessibility tools like screen readers and speech recognition systems, but the same automation client technology is quite useful for this role. You can learn more about automation and accessibility on MSDN.

The UI Map also contains the “recorded methods” that form the macro. Normally you see these in a designer window, but you can convert them into raw source code. Beware though, this conversion is one way and cannot be undone.


Once you have your recordings fine-tuned, it is time to start writing tests. Below is an example of a simple test to ensure that a checkbox is cleared at the end of the sequence.

As you can see, the same concepts you find in unit tests apply to Coded UI tests. However, Coded UI tests do have some extra considerations. Since the tests are run against a single instance of the application, the end-state of each test may interfere with the tests that follow.

There are some useful features in Code UI for examining test results. For example, when a test fails a screen shot is automatically taken and attached to the test results.

Coded UI is only available for the Premium and Ultimate versions of Visual Studio. Strangely, Visual Studio Test Professional 2012 will not include Coded UI.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • But their Unit Test Runner does not support CodedUI Test

    by Yetao Chen,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I just submit a support issue days ago

    What their feedback is:
    'We appreciate your feedback. Unfortunately, this is a current limitation of the CodeRush Unit Test Runner. It does not support CodedUI tests. We are going to eliminate this limitation by implementing the mentioned support with one of our future releases.'

    Link is there:

  • Incorrect info

    by digit guy,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    This sentence isn't correct.
    "...when a test fails a screen shot is automatically taken and attached to the test results..."

    CodedUI doesn't take snapshots automatically. However, it does record the playback of tests, but it takes the complete video of test execution independent of whether the test pass or fail.

    To take snapshot at the end of fail test, you need to write your own code.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p