我正在尝试创建测试用例并将它们添加到现有的基于需求的套件中。
下面是我正在尝试使用的代码,但我能够创建测试用例但无法将它们添加到基于需求的套件中
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Uri tfsUri = new Uri("http://tfsint:8080/tfs/sandbox/");
string teamProjectName = "Scrum Custom";
TfsTeamProjectCollection Tfs = new TfsTeamProjectCollection(tfsUri);
ITestManagementService service = (ITestManagementService)Tfs.GetService(typeof(ITestManagementService));
ITestManagementTeamProject TestProject = (ITestManagementTeamProject)service.GetTeamProject(teamProjectName);
//ITestPlanCollection testPlanCollection = TestProject.TestPlans.Query("SELECT * FROM TestPlan");
int myPlansId = 2009;
ITestPlan foundPlan = TestProject.TestPlans.Find(myPlansId);
Console.WriteLine("Got Plan {0} with Id {1}",
foundPlan.Name, foundPlan.Id);
//ITestSuiteBase newSuite = TestProject.TestSuites.Find(myTestSuiteId);
我在这里遇到了 IRequirementTestSuite 的问题,可能是语法不同
int myTestSuiteId = 2037;
IRequirementTestSuite newSuite = TestProject.TestSuites.Find(myTestSuiteId);
ITestConfiguration defaultConfig = null;
foreach (ITestConfiguration config in TestProject.TestConfigurations.Query(
"Select * from TestConfiguration"))
{
defaultConfig = config;
break;
}
ITestCase tc = TestProject.TestCases.Create();
tc.Title = "SAF test";
tc.Area = "Scrum Custom\\Selenium Integration POC";
//tc.Links.Add
tc.Save();
System.Windows.Forms.MessageBox.Show("test case id = " + tc.Id);
IdAndName defaultConfigIdAndName = new IdAndName(
defaultConfig.Id, defaultConfig.Name);
我如何在此处将测试用例添加到 IRequirementTestSuite
foundPlan.Save();
}
}
}