How to find the list of registered test controllers programmatically?


MTM shows you the list of registered test controllers in one of its page (Lab center –> Test controllers) where it shows the names of the test controller but in case you want to find the same information or want to find out other properties of the test controller, you can use the following script. Here are the steps you should perform to run this script.

  • Login to a machine with tfs object model installed. (The tfs object model gets installed with VS, MTM, Tfs, test controller etc)
  • Open notepad, copy paste the following script and change the highlighted variables as per your setup/deployment.
  • Open a power-shell command prompt and run the modified power-shell script.
  • It should show the registered test controllers

Enjoy !!

# Load Client Assembly 
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.TestManagement.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.TestManagement.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
 
# Define parameters 
$tfsCollectionUrl = New-Object System.URI("
http://myserver:8080/tfs/defaultcollection");
$projectName = "myproject";
 

# Find the test controllers registered with tfs
$tcmService = $tfsCollection.GetService([Microsoft.TeamFoundation.TestManagement.Client.ITestManagementService]);
$testControllers = $tcmService.TestControllers.Query();

foreach ($testController in $testControllers)
{
  Write-Host $testController
}

Comments (0)

Skip to main content