如何检索启动自动化测试的工作项的ID [英] How to retrieve the ID of the workitem that started an automated test

查看:95
本文介绍了如何检索启动自动化测试的工作项的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简介:
在VS2012中,我们有一组计划自动化的工作项.我在VS2010中通过SpecFlow创建了一组自动化测试.要将工作项与自动化测试联系起来,我必须选择工作项并搜索只能是一种方法的自动化测试.

Introduction:
In VS2012, we have a set of workitems that are planned to be automated. I created a set of automated tests through SpecFlow in VS2010. To connect a workitem with an automated test, I have to select the workitem and search for the automated test that can only be exactly one method.

缺点是,由于有大量的TestMethods(而且我们有),所以列表很长.将WorkItem与相应的TestMethod连接起来将是一项繁琐的任务.因此,由于我们使用SpecFlow,因此会自动生成许多测试(以及由此的TestMethod名称).而且,当团队成员更改方案的名称时,该TestMethod的名称也会更改,从而断开了WorkItem和自动化测试之间的连接.

The drawback is that with a large amount of TestMethods (and we have), the list is very long. It will be a tedious task to connect a WorkItem with the corresponding TestMethod. Thereby, lots of our tests (and therefore the TestMethod names) are generated automatically because we use SpecFlow. And when a teammember change the name of the scenario, this TestMethod name is also changed, breaking the connection between the WorkItem and the automated test.

我想要的东西:
我想创建一个可以为每个自动化工作项选择的TestMethod.此TestMethod检索工作项ID,并搜索以该ID开头或具有带有该ID的SpecFlow Tag属性的TestMethod.因此,我需要工作项的ID.

What I want:
I want to create a single TestMethod that can be selected for each automated workitem. This TestMethod retrieves the workitem ID and searches for a TestMethod that starts with that ID, or has a SpecFlow Tag attribute with that ID. Therefore I need the ID of the workitem.

问题:
如何检索启动测试的工作项的ID?

Question:
How do I retrieve the ID of the workitem that initiated the test?

推荐答案

我找到了在TFS中为Microsoft测试管理器执行的测试检索工作项的测试用例ID的解决方案:

I found the solution for retrieving the test case ID for a workitem in TFS for tests that are executed by Microsoft Test Manager:

string tcId = TestContext.Properties["__Tfs_TestCaseId__"].ToString();

提供了此方法在TestClass对象中. TestClass对象自动获取一个TestContext实例. MTM正在使用TestContext向正在运行的TestMethod提供信息.

Provided that this method is in a TestClass object. A TestClass object automatically gets a TestContext instance. MTM is using the TestContext to serve information to the TestMethod it is running.

(未记录的)属性的完整列表可以在

A full list of the (undocumented) properties can be found on the blog of InfoSupport.

这篇关于如何检索启动自动化测试的工作项的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆