DevOps Zone is brought to you in partnership with:

I'm an independent consultant working in Italy with more than 8 years of experience in designing and developing application for .NET framework, both in windows and Web environments. I'm particularly involved in Continuous Integration strategies, and designing infrastructure of applications, since I'm a lover of pattern and Application Lifecycle Management. I'm a great fan of Communities and I'm a co-founder of DotNetMarche, an Italian community focused on .NET development and I love blogging about technology. Ricci is a DZone MVB and is not an employee of DZone and has posted 40 posts at DZone. View Full User Profile

Running Coded UI Tests in a Virtual Machine

06.11.2013
| 3016 views |
  • submit to reddit

Code UI Tests are an effective way to test your UI through automation -- they absolutely are not a substitution for Unit Testing, but they can be used effectively to verify the whole application behave as expected. The most annoying part of Coded UI Tests is that while they are running you cannot do anything else on the computer, because mouse and UI are used to run the test. This leads to a very common question:

Is it possible to run Coded Ui Test in a Virtual Machine instead that in my primary machine?

The answer is yes, and it is a really simple task to accomplish. First of all install a Test controller on a machine in your network (or a virtual machine if you want to run test inside a local VM) and configure it.

image

Figure 1: Configure user used to run the service and nothing more

You need only to specify the account used, and you should not register it to a Team Project Collection, just leave any other option blank. Then you need to install Test Agent on the same machine or to another one, and configure that test agent to connect to the previous installed test controller.

image

Figure 2: Configure the agent to log on automatically and connect to the test controller

Now you should see that the Agent component connects to the controller and the Test Agent Status is online

image

Figure 3: The test agent is online and connected to the controller.

It is time to go back to Visual Studio, right-click on the solution name and add new item, from the list of templates choose Test Settings

image

Figure 4: Add a test settings to the solution

Even if in VS 2012 test settings are not used by default as in VS2010 they are still there. In VS 2012 you do not usually need a Test Settings file, unless you want to run tests with some non standard configuration, as in this example. Once you have added a Test Settings file you can edit it and choose to execute test remotely specifying the name of the machine that has the Test Controller installed.

image

Figure 5: Choose to run test with Remote Execution

Now you should simply save the file, and choose as the active test settings browsing for the file

image

Figure 6: Activate test settings

Now if you run again the Coded UI Test it will be run in the machine with the test agent.

image

Figure 7: The VM with test agent runs tests for me

Thanks to this configuration you can execute any Unit Test in a remote machine, not only CUIT.

Published at DZone with permission of Ricci Gian Maria, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)