简体   繁体   中英

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.

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.

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.

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? And therefore the ability to have many MTM/TFS Test Cases associated to that SINGLE C# Test Class?

If you are looking to get test case id from code within a test case class, you can get it from the TestContext instance. 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/

The following code will give you the test case Id

var testCaseId = TestContext.Properties["__Tfs_TestCaseId__"].ToString()

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM