How to find the action recording associated with the test?

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=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.TestManagement.Client, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.TestManagement.Common, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”);
# Define parameters
$tfsCollectionUrl = “
$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
  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
  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.

Comments (3)
  1. Sam Riffle says:

    How can I prevent someone from deleting a test run. We can't just have anyone deleting a test run or removing an associated action recording.

  2. Dilip Pal says:


    I ran a test case from MTM and created the action recordings then i associated those action recording in MTM & TFS. Now, how to see generated code for Action recording of test case in visual studio.?

  3. Trina says:

    This is a great blog.  I wish I wasn't stuck using this software.  It is terrible for actual testers.  Did Developers create it?

Comments are closed.

Skip to main content