c# – TFS 2015:为测试用例添加测试步骤
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – TFS 2015:为测试用例添加测试步骤,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3036字,纯文字阅读大概需要5分钟。
内容图文
![c# – TFS 2015:为测试用例添加测试步骤](/upload/InfoBanner/zyjiaocheng/774/e2f6e125eab34ef2beef92ea202211a2.jpg)
我正在尝试以编程方式创建测试计划,包括测试套件和测试用例.问题是在我的测试用例中添加测试步骤.此代码使用测试套件和测试用例正确创建了测试计划,但未在我的测试用例中创建测试步骤.我哪里错了?
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.Query(
"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中添加一步.
更多细节:
内容总结
以上是互联网集市为您收集整理的c# – TFS 2015:为测试用例添加测试步骤全部内容,希望文章能够帮你解决c# – TFS 2015:为测试用例添加测试步骤所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。