简体   繁体   中英

Get test case outcome/result using TFS API

how to Get Current test case result especially that which Active, because alawys i get Passed. enter image description here

You could first retrieve Active test cases is to use the ITestPlan.QueryTestPoints method, and TestPointState.Ready property.

The following code snippet will list all the Active test cases' Id . Please take a look at below:

ITestManagementService testManagementService = testHelper.GetTestManagementService();
            //Get Team Project
            ITestManagementTeamProject teamProjects= testManagementService.GetTeamProject("TeamProjectName");
 //Get the test plan
            ITestPlan testPlan=teamProjects.TestPlans.Find(int.Parse("3")); //3 is the test plan id on my side
            // Get test points
            ITestPointCollection testPoints= testPlan.QueryTestPoints("SELECT * FROM TestPoint");
            foreach (var item in testPoints)
            {
                if (item.State==TestPointState.Ready)
                {
                    Console.WriteLine(item.TestCaseId);
                }
            }

Then you just need to get the listed CaseID's status. If your want to get the running test Step's results, you could also take a look at this blog: MTM Testing Scorecard using TFS API

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