Good day!
I try to parse tree on test plan tfs 2010.
So, i can get Test Plan:
var planOld = helperOldProject.GetTestPlan("TestProject", 10); // 10- id of test plan
ITestManagementTeamProject project1 = helperNewProject.GetProject(sourceserverurl, sourceproject);
Then i create new Test Plan Programmatically:
//Create a Test Plan Programmatically
ITestPlan planNew = project1.TestPlans.Create();
planNew.Name = planOld.Name;
planNew.StartDate = DateTime.Now;
planNew.EndDate = DateTime.Now.AddMonths(2);
planNew.AreaPath = "TestArea";
planNew.Description = planOld.Description;
planNew.State = planOld.State;
// other attributes: plan.AreaPath, plan.Description,plan.State
planNew.Save();
And then i need to parse RootSuite tree:
var suiteOld = planOld.RootSuite;
// Parse Root:
IStaticTestSuite suiteNew = project1.TestSuites.CreateStatic();
suiteNew.Title = suiteOld.Title;
planNew.RootSuite.Entries.Add(suiteNew);
foreach (var tcc in suiteOld.TestCases)
{
var tc = helperOldProject.teamProject.TestCases.Find(tcc.Id);
var tc2 = helperNewProject.teamProject.TestCases.Create();
tc2.Description = tc.Description;
tc2.Owner = tc.Owner;
tc2.Title = tc.Title;
tc2.Save();
suiteNew0.Entries.Add(tc2);
planNew.Save();
}
And then i need to parse SubTree:
CreateSubTree(ref project1,ref planOld,ref planNew,ref helperOldProject,ref helperNewProject);
public static void CreateSubTree(ref ITestManagementTeamProject project1,ref ITestPlan planOld,
ref ITestPlan planNew,ref Helper helperOldProject,ref Helper helperNewProject)
{
Console.WriteLine("SubSuites.Count: " + planOld.RootSuite.SubSuites.Count);
foreach (ITestSuiteBase suiteOld in planOld.RootSuite.SubSuites)
{
IStaticTestSuite suiteNew = project1.TestSuites.CreateStatic();
// planNew.RootSuite.SubSuites.Add(suiteNew);
IStaticTestSuite staticSuiteOld = suiteOld as IStaticTestSuite;
foreach (ITestSuiteEntry tccOld in staticSuiteOld.TestCases)
{
suiteNew.Title = suiteOld.Title;
planNew.RootSuite.Entries.Add(suiteNew);
//planNew.RootSuite.SubSuites.Add(suiteNew);
var tc = helperOldProject.teamProject.TestCases.Find(tccOld.Id);
var tc2 = helperNewProject.teamProject.TestCases.Create();
tc2.Description = tc.Description;
tc2.Owner = tc.Owner;
tc2.Title = tc.Title;
tc2.Save();
suiteNew.Entries.Add(tc2);
}
Console.WriteLine(suiteOld.TestSuiteEntry);
}
}
So, i parse new one subtree element, but i know,that after that node i have another one node.Like this:
Root: element1,element2,element3 ...
--- Node1:element1,element2....
-------- Node2: element1,element2...
But planOld.RootSuite.SubSuites.Count==1; And i see elements only of Root and Node1.
And another problem is to create new sub tree: This code doesnt works:
planNew.RootSuite.SubSuites.Add(suiteNew); // cannot add,remove item error.
Please, help me to parse it! And why i cannot add sub node at tree?
Thank you!