简体   繁体   中英

How to add associated automation in MTM through code

I have a test case in MTM named 'myTestCase'. I also have a unit test code (c#) which is corresponding to 'myTestCase'. Adding associated automation in MTM could be done manually, but is there any way by which I could use some code so that the 'Associated Automation' will be added? In other words, i need a code that will connect the unittest code with the Test case in MTM, so that I don't need to link it manually. Sorry, if this sounds dumb. Thank you for the help!

Thank you @chief7, it helped me solve my query.

For those facing with the same proble, the above mentioned link will help you. I'm posting the code snippet.

This will help in adding the associated automation to the testcase. The required details are automation testname (should be in the format Projectname.Namespace.functionname , eg. Unittest1.Mynamespace.Myfunction) , automation test type , (eg. Unittest) , and automation storage name eg.(UnitTestProject1.dll)

SHA1CryptoServiceProvider crypto = new SHA1CryptoServiceProvider();
byte[] bytes = new byte[16];
Array.Copy(crypto.ComputeHash(Encoding.Unicode.GetBytes(automationTestName)), bytes, bytes.Length);
Guid automationGuid = new Guid(bytes);

 testCase.Implementation = testCase.Project.CreateTmiTestImplementation(
            automationTestName, automationTestType,
            automationStorageName, automationGuid);
testCase.Save(); 

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