Running Coded UI Tests (from action recordings with MTLM) in Team Builds (TFS2010)

With Visual Studio 2010 (Premium/Ultimate) we are able to create several types of automated tests. Automated tests will execute a sequence of test steps and determine whether the tests pass or fail according to expected results.

Coded UI Tests provide functional testing of the user interface and validation of user interface controls.

How to create Coded UI Tests? You could create them directly into Visual Studio, but for this blogpost I want to start from an action recording in Microsoft Test and Lab Manager (MTLM). An action recording is quite useful in manual tests that you need to run multiple times and for recycling common steps in different manual tests that contain shared steps.

I did create a simple test case with different test steps in MTLM to test some behavior on my website.

TestCaseDefinition

From MTLM I started a test run for this test case.

TestSuiteOverview

Before running the test, I do need to check the action recording to be sure to capture my actions for this test.

CreateActionRecording

The Test Runner will give a detailed overview of the recorded actions. Afterwards you will be able to replay all these stored actions in the Test Runner.

ActionRecordings 

After saving the results of this test run (all data is associated to my test case) it’s time to open Visual Studio 2010 and to create a Coded UI Test.

TestCaseAttachments

CodedUITestStart

Instead of choosing the default option to record actions I did choose to use an existing action recording after which I need to retrieve the appropriate test case to link to the associated actions.

ActionRecordingPicker

By clicking OK, Visual Studio will start generating code that will represent my actions that were recorded in Microsoft Test and Lab Manager. On top of that you are also able to add assertions on parts of the user interface in a separate Coded UI Test that you may reuse in other Coded UI Tests.

CodedUITestAssertions

Now, let’s integrate this entire UI test (MyCodedUITest) into the automated build. I created a default new build defintion where I also enabled to run the automated tests.

BuildDefinition

To run unit tests that interact with the desktop during a Team Build, we need to modify the Build Service Host properties in the Team Foundation Administration Console to run the build service as an interactive process instead of running the build service as a Windows Service.

BuildServiceHost

That’s about it. Make sure that the Build Service Host is running in the command line that will pop up after starting the BuildServiceHost. Queue the build and explore the results!

TestResults

Done!

With this post I wanted to highlight the powerful integration of (automated) testing into the upcoming Visual Studio 2010 offering.

5 Responses to Running Coded UI Tests (from action recordings with MTLM) in Team Builds (TFS2010)

  1. Dieter says:

    Pieter,

    Nice and clear article, but is this also working for winforms?

    Dieter

  2. @Dieter,

    yes, this is also possible with Winforms/WPF applications.

    Pieter.

  3. shilpa says:

    hi
    in my webpage the labels appear random with a drop down to select one number
    for example
    enter 1 pin and 2 pin
    when i record this and playback
    the webpage will ask me
    enter 2 and 5 pin

    how do i code to find the random label displayed in the coded ui test

  4. Pat says:

    Hi,

    I don’t understand the following sentence

    ‘Make sure that the Build Service Host is running in the command line that will pop up after starting the BuildServiceHost.’

    What do I need to do?

    grtz,
    P.

  5. @Pat:

    running the build service interactively (instead of as a Windows service) will automatically pop up a command line window that will listen to build requests on port 9192.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: