Hi,
I am trying to create a Win App where i can read test case from one project of one TFS and then move to another project in another TFS. I was able to implement the same but i want to migrate the test steps as well as the test data.
This is what i have written now
To show the test case in a datagrid
WorkItemStore workItemStore = new WorkItemStore(_TfsTeamProjectCollection);
queryResults = workItemStore.Query(
"Select [State], [Title] " +
"From WorkItems " +
"Where [Work Item Type] = 'Test Case' AND [Team Project]='" + _ProjectInfo.Name + "' " +
"Order By [ID] Asc ");
DataTable dtWorkItem = new DataTable();
dtWorkItem.Columns.Add("Title", typeof(string));
dtWorkItem.Columns.Add("State", typeof(string));
dtWorkItem.Columns.Add("Created By", typeof(string));
dtWorkItem.Columns.Add("Created On", typeof(string));
foreach (WorkItem workItem in queryResults)
{
dtWorkItem.Rows.Add(workItem.Title, workItem.State, workItem.CreatedBy, workItem.CreatedDate);
}
dsWorkitems.Tables.Add(dtWorkItem);
if (dsWorkitems != null)
{
testCaseGrid.DataSource = null;
testCaseGrid.DataSource = dsWorkitems.Tables[0];
}
Then to Import data to the target tfs project
public void SaveWorkItem(WorkItemCollection workItemCollection)
{
try
{
int conflictCount = 0;
Project _Project;
WorkItemType _WorkItemType;
WorkItem _WorkItem = null;
WorkItemStore _WorkItemStore = new WorkItemStore(_TfsTeamProjectCollection);
foreach (WorkItem workItem in workItemCollection)
{
if (workItem.Id > 0)
{
_Project = _WorkItemStore.Projects[_ProjectInfo.Name];
_WorkItemType = _Project.WorkItemTypes["Test Case"];
_WorkItem = CheckWorkItemExist(_WorkItemStore, _WorkItemType, workItem.Title);
if (_WorkItem == null)
{
_WorkItem = new WorkItem(_WorkItemType)
{
Title = workItem.Title,
Description = workItem.Description
};
}
else
{
conflictCount++;
objLog.LogEvent("Test Case already exists. Work Item ID: " + workItem.Id + ". Work Item Title:" + workItem.Title);
}
}
}
if (conflictCount == 0)
{
MessageBox.Show("All Work Items Imported Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
objLog.LogEvent("Imported Successfully!!!", "Information");
}
}
catch (Exception ex)
{
throw ex;
}
}
Now i want to migrate the test steps as well as data. Can anyone please help me