Coded UI Test from Microsoft Test & Lab Manager

After you have created a Coded UI Test and added it to a Team Build, you can run the test from a Microsoft Test & Lab Manager (MTLM). In this post, i will describe the steps to enable this.


Since Coded UI Tests always interact with the UI, the Test Agent has to be run as interactive process.

See How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop


Step 1: Associate the Coded UI Test to the Test Case.

a. In Visual Studio, Open the Coded UI Test Project.

b. Open the Test Case from Team Explorer.

c. Navigate to the Associated Automation tab.


d. Click on … button next to Automated Test Name & Choose the CodedUITestMethod and save the test Case.




Step 2: Setup the environment for running a Coded UI Test.

a. In Microsoft Test & Lab Manager, Navigate to the Lab tab and create a new Physical Environment.


Add an available machine to the environment and give it the role of Desktop Client.



Finish the activity.


c. Navigate to the Test Settings tab and create a new Test Settings.

Choose to Run Automated tests.


Select the Desktop Client role. The environment that we created earlier matches this role.


Finish the activity.


d. Navigate to the Testing Center and choose the Properties of the Plan.

Set the Test Settings & Test Environment for Automated Runs.

Set the Filter for Builds and Build in Use also.



Save and close the Test Plan.


e.  Click on Plan activity.

Add the Test Case (seen in Step 1) to the new Test Plan.


Step 3: Run the Coded UI Test from Microsoft Test & Lab Manager

Navigate to the Testing Center & choose Test tab.

Right click on the Test Case and choose Run.



The status of the Test Run is shown in MTLM.



The Coded UI Test will be run on the specified environment.

Comments (8)

  1. cheater says:

    Hi Mathew,

    I’ve created an Coded UI Test and I want to run it with Test Manager. And I’ve read the configurations that must be done. Wow!!! Built agents, test agents, Hyper-V Host, SCVMM…. If I can run the test from visual studio, if I want to run them from Test Manager why do I need a virtual machine? I’ve associated my test method from my project with an test case in Test Manager, I’ve installed build agent, test agend, Hyper-v Host, but when I’ve read about SCVMM, I didn’t knowed what to do… And my main question is: Do I really need all of that stuff?

  2. You don’t have to setup Hyper-V host and SCVMM if we are not using Lab Management. The minimal setup would be as I have described above. In this blog, i use a Physical environment which does not require Hyper-V and SCVMM.

    Also note that this is a first time setup cost. You will be able to reuse this setup for your entire testing effort afterwards.

  3. cheater says:

    Hi Mathew,

    do you know why I can not create physical environments?

    Th e option "New physical environment" is disabled (read only).

  4. You need to install a Test Controller and register it with Team Foundation Server.

  5. cheater says:

    When I reach at Step 2, d, I can not select any built in use. How can I create one? I have already two build definitions.

  6. In Team Explorer, you will have to create a Build Definition for your project and then Queue a build.

  7. cheater says:

    is it possible to have two built services? I ask that because we have here two collections and when I need to create a build, I need to set the service for my collection (as I said, we have more than one project). Thanks