locked
Link between Test Case Result and Test Case ID RRS feed

  • Question

  • Hello Team,

    Is there a way to find out the reference to ITestCaseResult object based on Test Case ID.

    All the forums make use of Test Run ID in order to find ITestCaseResult. Can we bypass this step and use only Test CaseID.

    Otherwise can i use the table DimTestResult to get results.

     

    Thanks,

    Keerthi

     

    Thursday, January 19, 2012 6:54 AM

Answers

  • Thank you for your response John. I couldn't use this as I don't have the run id with me.

    I found an alternate solution which uses the below statement:

    this._project.TestResults.Query("SELECT * FROM TestResult WHERE TestCaseID = X");

     

    Thanks,

    Keerthi

    Monday, January 23, 2012 7:58 PM

All replies

  • Hi Keerthi, 

     

    Thanks for your post.

     

    I think we can query that DimTestResult table to get result, to query the TestCaseID field and ExecutionID(TestRunId.TestResultID) field.  

     

    To link between test results and test case, I can using the API, please refer to this 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);

    }

    Similarly test cases which are Passed, Aborted, etc. can be found out by passing TestOutcome.Passed , TestOutcome.Aborted, etc. For more information, please refer to this article: http://social.technet.microsoft.com/wiki/contents/articles/3279.tfs-2010-api-get-results-of-a-test-run.aspx.

     

    If you use the Test Management(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
    Friday, January 20, 2012 8:33 AM
    Moderator
  • Thank you for your response John. I couldn't use this as I don't have the run id with me.

    I found an alternate solution which uses the below statement:

    this._project.TestResults.Query("SELECT * FROM TestResult WHERE TestCaseID = X");

     

    Thanks,

    Keerthi

    Monday, January 23, 2012 7:58 PM
  • Hi Keerthi, 

     

    Thanks for your reply.

     

    And thank you for sharing your experience here. It will be very beneficial for other community members having the similar questions.

     

    All your participation and support are very important to build such harmonious/ pleasant / learning environment for MSDN community.


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 24, 2012 3:21 AM
    Moderator