{A}
在我以前的关于TFS的API的后,我表明了如何创建和获取测试计划,测试套件和测试用例对象。
作为质量中心TFS 2010迁移工具的一部分,我翻译成TFS 2010地区质量中心的层次。
,正如你可以看到从下面的图片,QC的层次结构(中间图片)看起来TFS的区(左图)相同,但它不会有同样的感觉吗??
感觉一样吗?当使用质量控制,您可以浏览使用树视图,深入的测试套件(文件夹)你想,以实现在TFS这些行动必须编写一个查询和每次改变查询的值,Ammm???它的不是一个好的解决方案??
但是,使用Microsoft测试管理,您可以创建具有相同的层次结构(右图)作为QC测试套件和要求。
为了迅速在TFS中创建这些层次,我只是建立了一个工具。此工具使用下面的文章来完成这个任务:{A5}
该工具很简单吗??连接到TFS 2010,创建或选择测试计划,选择区域(一个或多个),然后点击开始。
这一行动将采取两分钟,你到底在MTM的基础上,在您的项目和测试在每个区分配的案件区的结构完整的层次。
{A6}
结果将里面的测试计划,你拿起之前,所有的测试套件将在当前团队项目区路径。
在每个测试套件,你应该看到相关的测试用例。
{A7}
{A8}代码示例
/// <summary>
/// Get's a full path of Area, split it and for each part create
/// Test Suite and apply the Test Cases beneath it.
/// </summary>
/// <param name="full_area">Area Path, for example -
/// CMMI\First Area\Sub Area\Content Area</param>
void CreateTestSuite(string full_area)
{
try
{
string[] areas = full_area.Split('\\');
string full_path = string.Empty;
IStaticTestSuite suite = null;
string current_area = string.Empty;
for (int i = 0; i < areas.Length; i++)
{
if (!string.IsNullOrEmpty(areas[i]))
{
string area = areas[i].RemoveBadChars();
current_area += area;
//The first item, find it and assigned to suite object.
if (i == 1)
{
ITestSuiteEntryCollection collection = _plan.RootSuite.Entries;
suite = TestHelper.FindSuite(collection, area);
if (suite.Id == 0)
{
suite.Title = area;
TestHelper.AddTests(suite, current_area);
_plan.RootSuite.Entries.Add(suite);
}
}
else
{
ITestSuiteEntryCollection collection = suite.Entries;
//* collection - Perform search only under the suite.Entries
//- Duplicate items allowed.
IStaticTestSuite subSuite = TestHelper.FindSuite(collection, area);
if (subSuite.Id == 0)
{//Cannot find Test Suite
subSuite.Title = area;
suite.Entries.Add(subSuite);
//After creating the Test Suite
//- Add the related TestCases based on the Area Path.
TestHelper.AddTests(subSuite, current_area);
}
suite = subSuite;
}
current_area += "\\";
_plan.Save();
}
}
_plan.Save();
}
catch (TestSuiteInvalidOperationException testex)
{
if (!testex.Message.Contains("Duplicate suite name detected"))
throw new ArgumentNullException(testex.Message);
}
}
TestSuiteHelper包含几个简单的动作,如AddTests - 执行查询,以查找特定的区域路径下的所有测试用例,还为每间套房(递归搜索下一个递归搜索FindSuite在TFS,因为套房不具有唯一的名称,这应该是每间套房的个人搜索)。{C}{A10}