static voID Main(string[] args) { try { var tfs = TfsHelper.TryToAutenticated(); var wis = tfs.GetService<WorkItemStore>(); //TEST PLAN // Let's create a new Test Plan from scratch // Only the name property is required to be set before // you can save,but we'll set a few extras here as well. ITestManagementService service = (ITestManagementService)tfs.GetService(typeof(ITestManagementService)); ITestManagementTeamProject myTestManagementTeamProject = service.GetTeamProject("GammaEnterprise"); ITestPlan newTestPlan = myTestManagementTeamProject.TestPlans.Create(); newTestPlan.name = "My Test Plan"; newTestPlan.Save(); //TEST SUITE // Next let's add a new Test Suite to our plan // First,create a static suite (I'll cover Dynamic Suites // in a future post) IStaticTestSuite newSuite = myTestManagementTeamProject.TestSuites.CreateStatic(); newSuite.Title = "My Suite"; newTestPlan.RootSuite.EntrIEs.Add(newSuite); newTestPlan.Save(); //TEST CASE // Let's find the default configuration that was created when // we created our Team Project. We'll need this to add some // tests to our new suite (or we Could create a new one,but // I'll keep things simple and just get the default one for Now) ITestConfiguration defaultConfig = null; foreach (ITestConfiguration config in myTestManagementTeamProject.TestConfigurations.@R_419_5962@( "Select * from TestConfiguration")) { defaultConfig = config; break; } // I would typically check that defaultConfig is not null here // but for brevity sake will skip that. // Next we'll create a Testcase to add to our Test Suite ITestCase tc = myTestManagementTeamProject.TestCases.Create(); tc.Title = "Verify X"; //HERE THE PROBLEM---------------------- ITestStep ts = tc.CreateTestStep(); ts.TestStepType = TestStepType.ActionStep; ts.Description = "Description"; ts.Title = "Title"; //--------------------------------------- tc.Save(); // Now let's add it to your suite,we still have our reference // to the static suite around so we'll use that // First we need an "IDAndname" object for our config IDAndname defaultConfigIDAndname = new IDAndname(defaultConfig.ID,defaultConfig.name); // Now we'll set the default configs for our suite newSuite.SetDefaultConfigurations(new IDAndname[] { defaultConfigIDAndname } ); // Now let's add that testcase newSuite.EntrIEs.Add(tc); // Now let's save the plan (don't need to explicitly // save test suites). newTestPlan.Save(); } catch(Exception ex) { Console.Writeline(ex.Message); Console.Readline(); } }解决方法 您可以使用命名空间:Microsoft.TeamFoundation.TestManagement.ClIEnt
例如:
var step = testCase.CreateTestStep(); step.Title = "Step 1 @param1"; step.ExpectedResult = "Expect 1 @param2"; testCase.Actions.Add(step); testCase.Save();
所以我认为你只需要在Actions中添加一步.
更多细节:
https://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.testmanagement.client.itestbase.actions.aspx
总结以上是内存溢出为你收集整理的c# – TFS 2015:为测试用例添加测试步骤全部内容,希望文章能够帮你解决c# – TFS 2015:为测试用例添加测试步骤所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)