I was looking at this question on the MTM forum and wanted to find out answers for following 2 questions.

  1. How can a user find out whether an action recording is associated with a test or not?
  2. How can a user delete the associated action recording?

For #1, I coded a small power-shell script which can find answer to #1 and in addition it emits the details of the associated action recording attachment (if there is one). Here is that script.

# Load Client Assembly
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.TestManagement.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.TestManagement.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
 
# Define parameters
$tfsCollectionUrl = “
http://myserver:8080/tfs/DefaultCollection”;
$projectName = "myProject";
$testCaseId = "9";

# Connect to tfs
$tfsCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsCollectionUrl);
$tcmService = $tfsCollection.GetService([Microsoft.TeamFoundation.TestManagement.Client.ITestManagementService]);
[Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject] $tcmProject = $tcmService.GetTeamProject($projectName);

# Query for action recordings
$actionRecordingsProperty = [Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject].GetProperty("ActionRecordings").GetGetMethod();
$actionRecordings = $actionRecordingsProperty.Invoke($tcmProject, "instance,public", $null, $null, $null);

$actionRecording = $actionRecordings.GetDefaultForTestCase($testCaseId);

Write-Host ” ================================ “
Write-Host “ActionRecording: “$actionRecording

The output this script produced for one of my test which has action recording is as follows: -

ActionRecording:  TestResultAttachment instance 12611187
  ActionPath:
  AttachmentType: AfnStrip
  Comment: Action recording created for the test case
  CreationDate: 11/19/2012 12:18:01 AM
  DownloadQueryString: type=rsa&sfid=2139,0,0,0,0,0,0,0,0,0,0,0,0,0,0&ts=634889992624193163&s=hGmis7qVPfneEQa8Y%2FNcC7Ujtz9NeCs40m7cFpYZGcgHieAJsmwewbqFGkivzEnDpgbYHny2yNc3
HTZWO0iN27j6RohOPl%2BijVkFK7jOehl7h%2Fy3dcfi3Ciz0D8xRd5Zyoh7qfweFuv6LkVc0o7poKtmRi4yZPmPt0o1waL%2BiiPX0byjGGg%2FK0w82E4p7Z495sg7j0UDOO3QGb%2FNmpW7znw8b4wqn2oSwlnSWNhKM40RBk
RAHcwG6b2oZ%2B3WZ0scfINeYLLMHMP1Hni3t%2FYylhUQuQNSyOE%2F6ntTpCMT7BineOr1TafY8rX0yM9wcY6TbffErQCuPHYwSPlJIRiRdg%3D%3D&fid=2139&iid=118fd303-fbec-418e-ae6d-067ee1a797b4&cp=/t
fs/DefaultCollection/
  FileName: TC9.uitest
  Id: 101
  IsComplete: True
  IterationId: 0
  Length: 13558
  SessionId: 0
  TestResultId: 100000
  TestRunId: 48
  TmiRunId: 00000000-0000-0000-0000-000000000000

For #2, You can delete the test run in which the action recording was created. For example: – For my above associated action recording, if I delete test run with Id = 48, then the association is removed.