[英]How to dynamically get MTM/TFS Test Case ID calling associated automation
Right now our test base has 1:1 association in that for every Test Case on MTM/TFS - there is a C# test class that is associated to that test case only. 现在,我们的测试库具有1:1关联,因为对于MTM / TFS上的每个测试用例,都有一个C#测试类仅与该测试用例关联。
Within the test class the test case ID is hard coded as a value and that's how the data parameters are retrieved from the MTM/TFS Test Case to be executed at run time. 在测试类中,将测试用例ID硬编码为一个值,这就是从MTM / TFS测试用例中检索数据参数以在运行时执行的方式。
Unfortunately this has caused a lot of bloat and a lot of test cases that aren't much more than copy/pasted templates with the hardcoded test case Id being modified. 不幸的是,这导致了很多膨胀和很多测试用例,它们仅仅是修改/修改了硬编码测试用例ID的复制/粘贴模板而已。
Is there a way for a SINGLE C# TestClass to retrieve the data dynamically from the MTM/TFS Test Case that is associated with it? 单一C#TestClass是否有办法从与其关联的MTM / TFS测试用例中动态检索数据? And therefore the ability to have many MTM/TFS Test Cases associated to that SINGLE C# Test Class?
因此,是否有能力将多个MTM / TFS测试用例与该单个C#测试类相关联?
If you are looking to get test case id from code within a test case class, you can get it from the TestContext instance. 如果要从测试用例类中的代码获取测试用例ID,则可以从TestContext实例获取它。 The following blog post gives you the list of a properties present in the class.
以下博客文章为您提供了该类中存在的属性的列表。
http://fluentbytes.com/switching-browser-in-codedui-or-selenium-tests-based-on-mtm-configuration/ http://fluentbytes.com/switching-browser-in-codedui-or-selenium-tests-based-on-mtm-configuration/
The following code will give you the test case Id 以下代码将为您提供测试用例ID
var testCaseId = TestContext.Properties["__Tfs_TestCaseId__"].ToString()
Hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.