简体   繁体   English

如何动态获取MTM / TFS测试用例ID,以调用相关的自动化

[英]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.

相关问题 如何在mtm中获取当前的测试用例ID以进行数据驱动测试 - How to get current Test Case ID in the mtm for data driven test 如何使用c#更改MTM中测试用例的自动化状态? - How to change Automation Status of test case in MTM using c#? 如何通过代码在MTM中添加关联的自动化 - How to add associated automation in MTM through code 如何使用MTM将参数值从TFS中的测试用例传递到单元测试方法中的测试方法? - How to pass parameter values from test case in TFS to test method in unit test method using MTM? 如何在MTM中将两个测试脚本关联到单个测试用例 - how to associate two test script to single test case in MTM 在MTM中向测试用例添加附件 - Adding attachment to test case in MTM 如何将自定义自动化框架与MTM集成 - How to integrate Custom automation framework with MTM 如何在TFS 2017中获取当前的自动化测试运行ID - How to get current Run Id of automated test in TFS 2017 如何通过C#中的Release ID从TFS获取测试结果 - How to get test results from TFS by Release ID in C# 如何将自动化测试执行结果更新到 AzureDevOps/TFS 中的测试用例中 - How to update automation test execution results into the test cases in AzureDevOps/TFS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM