Reputation: 1
Im trying to update the field steps as with other fields
testCase.Fields["field"].Value = "value";
but is still empty after the change. How can I modify the steps in a Test Case?
Upvotes: 0
Views: 724
Reputation: 29976
Test Case is different with normal work items like Bug or Task. You need to use "ITestManagementService" in Microsoft.TeamFoundation.TestManagement.Client to update test case. Check the code below for reference:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.TestManagement.Client;
namespace TFSDownloadFile
{
class Program
{
static void Main(string[] args)
{
string url = "http://tfscollectionurl/";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(url));
ITestManagementService itms = ttpc.GetService<ITestManagementService>();
ITestManagementTeamProject itmtp = itms.GetTeamProject("YourProject");
//Get test case with test case id
ITestCase itc = itmtp.TestCases.Find(1);
//Get the first step in test case
ITestStep teststep = itc.Actions[0] as ITestStep;
//Update the test step
teststep.Title = "New Title";
teststep.ExpectedResult = "New ExpectedResult";
//Save the updated test case
itc.Save();
}
}
}
Upvotes: 1
Reputation: 1607
You'll want to use the Actions property. This will return a TestActionCollection that you can use to update the steps. You can use the ITestStep interface for each action in the collection to update the Title, Description, and ExpectedResult for each step. Don't forget to call Save()
on the workitem.
Upvotes: 0