Update status of the test case in MTM using c# -


i have assigned create c# application update test case status in mtm.

i tried below code , working fine. problem below code updating result if test case executed, not updating status of newly created test case(no history of run)

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using microsoft.teamfoundation.client; using microsoft.teamfoundation.workitemtracking.client; using microsoft.teamfoundation.testmanagement.client; using microsoft.teamfoundation.testmanagement.common; using system.io;  namespace updatetfs {     class program     {         static void main(string[] args)         {             //args[0] = testplanid; args[1] = testcaseid; args[2] = status; args[3] = configuration             int test_plan = int32.parse(args[0]);             int test_case = int32.parse(args[1]);             int test_config = int32.parse(args[3]);             int result_updated = 0;             textwriter tw = new streamwriter(@"c:\users\*\desktop\mtm.txt", true);              tw.writeline("attempting test case " +test_case+ "to marked "+args[3]);              //create tfs connection             tfsteamprojectcollection tfs = new tfsteamprojectcollection(tfsteamprojectcollection.getfullyqualifieduriforname("<tfs_url>"));              itestmanagementservice tms = tfs.getservice<itestmanagementservice>();              //connect project             itestmanagementteamproject proj = tms.getteamproject("<project>");              itestplan plan = proj.testplans.find(test_plan);               if (plan != null)             {                 itestcase tc = proj.testcases.find(test_case);                 if (tc != null)                 {                     itestpointcollection points = plan.querytestpoints("select * testpoint testcaseid =" + args[1]);                       foreach (itestpoint p in points)                     {                          var testresults = proj.testresults.bytestid(test_case);                        foreach (itestcaseresult result in testresults)                         {                             if (p.configurationid == test_config)                             {                                 if (args[2] == "failed")                                 {                                     result.outcome = testoutcome.failed;                                 }                                 else if (args[2] == "passed")                                 {                                     console.writeline("passed");                                     result.outcome = testoutcome.passed;                                 }                                 else if (args[2] == "notexecuted")                                 {                                     result.outcome = testoutcome.notexecuted;                                 }                                 result.save(true);                                 result_updated = 1;                                 tw.writeline("test case id =>" + test_case + "is marked " + args[2] + "mtm");                             }                         }                         if (result_updated == 1) { break; }                     }                     if (result_updated == 0)                     {                         tw.writeline(args[3] + " => configuration not found in test case " + test_case);                     }                 }                 else                 {                         tw.writeline(args[1] + " test case not found plan");                 }             }             else             {                 tw.writeline(args[0] + " plan not found in mtm");             }          tw.close();         }     } } 

someone me on this.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -