locked
Link between test results and test cases RRS feed

  • Question

  • Hi everybody,

    I'm trying to build some test documentation for one of our projects.

    I've some difficulties to bind the defined test cases to the test results...

    How can I retrieve the testcaseId from the test result? When I query the tfs_warehouse database and precisely the DimTestResults table, i can see the list of results of the test case execution but the test case id column value is always 0.

    I'm completely lost....

    Is anybody able to help me?

    Thanks in advance!

    Monday, July 11, 2011 4:00 PM

Answers

  • Hi Gilles,

     

    Thanks for your post.

     

    To get the test result from a test run, we should using TFS API, please view the following code snippet:

    TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(http://%3cserver%3e:8080/tfs/%3Ccollection%3E));

    ITestManagementService testManagement = (ITestManagementService)tfs.GetService(typeof(ITestManagementService));

    ITestManagementTeamProject testManagementTeamProject = testManagement.GetTeamProject(teamProject);

    // _testRunID is the Run ID of the Test Run

    ITestRun testRun = testManagementTeamProject.TestRuns.Find(_testRunID);

    // Get Failed Test Cases

    ITestCaseResultCollection testcases = testRun.QueryResultsByOutcome(TestOutcome.Failed);

    foreach (ITestCaseResult testcase in testcases)

    {

           // Print Test Case Details

           Console.WriteLine("TestCase ID: " + testcase.TestCaseId);

           Console.WriteLine("TestCase Title: " + testcase.TestCaseTitle);

           Console.WriteLine("Error Message: " + testcase.ErrorMessage);

    }

    For more information, please refer to this post: http://social.technet.microsoft.com/wiki/contents/articles/3279.aspx.

     

    If you use the Test Manager(MTM) to manage your Test Cases, I suggest you to post it at http://social.msdn.microsoft.com/Forums/en-US/vsmantest/threads for the better response. 


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, July 13, 2011 8:24 AM
    Moderator

All replies

  • When you look at the Test Case in MTM can you view the test results?

    Thanks,

    Gary

    Tuesday, July 12, 2011 11:19 AM
  • Hi Gilles,

     

    Thanks for your post.

     

    To get the test result from a test run, we should using TFS API, please view the following code snippet:

    TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(http://%3cserver%3e:8080/tfs/%3Ccollection%3E));

    ITestManagementService testManagement = (ITestManagementService)tfs.GetService(typeof(ITestManagementService));

    ITestManagementTeamProject testManagementTeamProject = testManagement.GetTeamProject(teamProject);

    // _testRunID is the Run ID of the Test Run

    ITestRun testRun = testManagementTeamProject.TestRuns.Find(_testRunID);

    // Get Failed Test Cases

    ITestCaseResultCollection testcases = testRun.QueryResultsByOutcome(TestOutcome.Failed);

    foreach (ITestCaseResult testcase in testcases)

    {

           // Print Test Case Details

           Console.WriteLine("TestCase ID: " + testcase.TestCaseId);

           Console.WriteLine("TestCase Title: " + testcase.TestCaseTitle);

           Console.WriteLine("Error Message: " + testcase.ErrorMessage);

    }

    For more information, please refer to this post: http://social.technet.microsoft.com/wiki/contents/articles/3279.aspx.

     

    If you use the Test Manager(MTM) to manage your Test Cases, I suggest you to post it at http://social.msdn.microsoft.com/Forums/en-US/vsmantest/threads for the better response. 


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, July 13, 2011 8:24 AM
    Moderator
  • Hi Gilles,

     

    If I have misunderstood anything, please describe your question in more detail and we will be able to provide the better response. 


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 14, 2011 9:46 AM
    Moderator