Using MTM Configurations with Lab Management

Outline

I was with a client, and they asked the entirely reasonable question, “How do we use the MTM test configuration to execute tests on a specific machine in our Lab environment”. I assumed that it would be out of the box behaviour, and was surprised it wasn’t.

If you do want it, here is the link to the uservoice: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2431738-let-mtm-test-configuration-os-and-browser-paramete

There is a great extension in a comment there, http://bzbetty.blogspot.co.nz/2013/02/tfs-extensibility-filtering-lab.html.

This post walks through the steps outlined in that post in step by step detail.

Setup

I have created a standard lab environment with 3 machines.

The Server is TFSALM2013 running TFS 2013 update 5.

The Lab Controller is WIN2012.

The Lab agents are TFSALM2013, WIN2012 and WIN2008R2.

The TFS server is also a lab environment, this is not best practice, however it was a fast way to prove out more than 2 machines.

When the environment is configured, I created machine properties that would match the configuration settings in Test Manager:

In Lab Center, Lab Settings, open the environment, edit the Machine Properties and add the relevant tags.

I have used the Tags OS and Database.

image

Once the environment is configured, then the agents will be ready in the Lab view:

image

Switching back to Test Manager (Blue mode from Green mode), I created matching test configurations:

image

Then assign those configurations that you want to run:

image

image

Create the plugin

To create the plugin, create a Class Library project, and add the references to the following assemblies, making sure you select the appropriate version for your TFS server:

 

image

The Assembly references are found:

Assembly Team Foundation Server 2013 Locations

Microsoft.TeamFoundation.TestManagement.Controller

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.TestManagement.Controller.dll

Microsoft.TeamFoundation.TestManagement.Client

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.TestManagement.Client.dll

Microsoft.VisualStudio.TestTools.Common

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.VisualStudio.QualityTools.Common.

Assembly Team Foundation Server 2015 Locations

Microsoft.TeamFoundation.TestManagement.Controller

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\o4dd5iui.om2

Microsoft.TeamFoundation.TestManagement.Client

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.TestManagement.Client.dll

Microsoft.VisualStudio.TestTools.Common

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.VisualStudio.QualityTools.Common.dll

Then insert the code from the blog, and compile the assembly.

Install on the Lab Controller

Copy the assembly to the lab controller, in the same directory as the controller configuration

image

then edit the QTControllerConfig.xml file after taking a backup, exactly as in the blog, using the namespace that you created the plugin with.

  <TestManagementPluginSection>
     <Plugins>
       <Plugin classname=”AgilityInMind.Tfs.TestManagement.Controller.AgentFilter.AgentFilterPlugin, AgilityInMind.Tfs.TestManagement.Controller.AgentFilter”/>      
     </Plugins>
   </TestManagementPluginSection>
</ControllerConfiguration>

This will restart the controller.

Running the Tests

Once your MTM test is associated with automation, then when you start a test run, it will route to the appropriate test agent.

image

Thanks to Betty for sharing this elegant solution!