Accessing MTM test case Id in an associated automation

Category: visual studio test

Question

SyAli on Mon, 20 Jun 2016 07:46:05


Hello Team,<o:p></o:p>

I have created automation framework in coded UI and associated that to multiple test cases in MTM and now run MTM test case with associated automation. That framework will extract the test case id of MTM test case and execute the test case based on the parameters provided in that MTM test case. <o:p></o:p>

But, now when I am selecting multiple test cases from MTM and running , than it is taking the last test case Id and run all scripts on that parameter. For e.g.

I have 3 test cases in MTM i.e. Scenario1, scenario2, scenario3.
Scenario1 has parameter :ScenarioID:4
Scenario2 has parameter :ScenarioID:5
Scenario3 has parameter :ScenarioID:6

When I select all the test cases and run those test cases with options.
Test cases run on test agent successfully. But all the test cases are running with parameter of Scenario3 i.e. parameter with value 6.
However when i am running single test cases than it is extracting correct id and taking its parameter only.

Please help me, how to extract MTM test case id when running multiple test case together and associated same Test Method with all.

Thanks in advance.

Replies

lake Xiao on Mon, 27 Jun 2016 06:53:31


Hi SyAlia,

>>I have created automation framework in coded UI and associated that to multiple test cases in MTM

Could you please tell me how did you define this automation framework.

To validate the cause is in the Test Method you associated. Please create another two code ui tests. Then associate the cases in MTM with these three code ui tests then try it again.

If still have the same problem. I think the problem is probably in the defination to get the test case id.

By the way, please take a look at the following thread and it give an example to get the test case id using TestContext.Properties["__Tfs_TestCaseId__"].ToString();

http://stackoverflow.com/questions/17995330/how-to-retrieve-the-id-of-the-workitem-that-started-an-automated-test/18272068#18272068

Best Regards,

Lake Xiao

SyAli on Mon, 27 Jun 2016 09:57:24


Hi Lake,

Thanks for the reply. 

The framework is a keyword driven framework and is a wrapper on coded ui. The test method of the framework is associated with the MTM test cases.  

I have 3 test cases in MTM i.e. Scenario1, scenario2, scenario3.
Scenario1 has parameter :ScenarioID:4
Scenario2 has parameter :ScenarioID:5
Scenario3 has parameter :ScenarioID:6

To extract the mtm test case i used   TestContext.Properties["__Tfs_TestCaseId__"].ToString(); 

When i am running single test cases than it is capturing  correct value. When i select all the test cases and run those test cases,Test cases run on test agent successfully. But all the test cases are running and capturing test case id for Scenario3 i.e. ScenarioID: 6.

How we can extract the ID for each test case when running complete suite.


lake Xiao on Tue, 28 Jun 2016 06:44:49


Hi SyAli,

I got the same result with yours. I have three cases in my MTM and the ID is 168, 169, 170.

When I run the individual case,  I can extract the ID correctly. But if I run the test suite for all three cases. It extract the one ID:170.

I also can't find out why have this problem. But I have found a workaround.

You could create three code UI test projects in one solution. Copy the test method into these three projects. And add the TestContext.Properties["__Tfs_TestCaseId__"].ToString() into three projects.  And associate these three projects with you cases in MTM one by one.

Then after running the test suite, you can extract the test case Id correctly.

Best Regards,

Lake Xiao

SyAli on Tue, 28 Jun 2016 08:16:08


Thanks for the quick response.

Actually i have approx 1000 test cases in MTM and with each test case I need to associate automation (Framework test method). If we are going to add coded ui test project for each test case then there will be no use of creating framework.

Could you please provide any work around in which we can capture the test case id for each test.

Thanks in advance.

lake Xiao on Wed, 29 Jun 2016 02:21:08


Hi SyAli,

I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

Best Regards,

Lake Xiao

IamMaverick on Wed, 13 Jul 2016 06:23:47


Hi Lake,

 Let us know about the update on this issue. This is creating issues for automation Execution. Waiting for your update.

Thanks


IamMaverick on Mon, 26 Sep 2016 07:10:48


Hi,

 Let us know about the update on this issue. This is creating issues for automation Execution. Still waiting for any update.

Thanks