Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6833031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:55:49+00:00 2026-05-26T22:55:49+00:00

I have found several samples about retrieving test results using the TFS API, but

  • 0

I have found several samples about retrieving test results using the TFS API, but no documentation on creating results programmatically. My aim is to create a lightweight alternative to using Microsoft Test Manager for running manual tests. Does anyone have experience with this? Are there any examples out there that I’m missing?

Here’s what I have so far:

ITestCaseResult CreateNewTestCaseResult(ITestSuiteEntry testCaseEntry)
{
    var run = testCaseEntry.TestSuite.Plan.CreateTestRun(false /* not automated */);
    run.AddTest(testCaseEntry.TestCase.Id, suiteEntry.TestSuite.DefaultConfigurations[0].Id, suiteEntry.TestSuite.Plan.Owner);
    run.Save(); // so that results object is created
    return run.QueryResults()[0];
}

I’m not sure if this is the correct way to initate a new run, and I’m not sure how to record results for each action of the test.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:55:50+00:00Added an answer on May 26, 2026 at 10:55 pm

    Update 15 Aug 2012:

    The sample below has now been integrated into my open source TFS Test Steps Editor tool. In the latest version it gained the ability to publish test results to TFS. See the source on GitHub.


    I now have working code for publishing test results. Note, the following code accepts ITestPoint (this represents a test case within a particular suite) and has some of my internal classes (not included) that just provide outcome and attachment paths for each step.

    var tfsRun = _testPoint.Plan.CreateTestRun(false);
    
    tfsRun.DateStarted = DateTime.Now;
    tfsRun.AddTestPoint(_testPoint, _currentIdentity);
    tfsRun.DateCompleted = DateTime.Now;
    tfsRun.Save(); // so results object is created
    
    var result = tfsRun.QueryResults()[0];
    result.Owner = _currentIdentity;
    result.RunBy = _currentIdentity;
    result.State = TestResultState.Completed;
    result.DateStarted = DateTime.Now;
    result.Duration = new TimeSpan(0L);
    result.DateCompleted = DateTime.Now.AddMinutes(0.0);
    
    var iteration = result.CreateIteration(1);
    iteration.DateStarted = DateTime.Now;
    iteration.DateCompleted = DateTime.Now;
    iteration.Duration = new TimeSpan(0L);
    iteration.Comment = "Run from TFS Test Steps Editor by " + _currentIdentity.DisplayName;
    
    for (int actionIndex = 0; actionIndex < _testEditInfo.TestCase.Actions.Count; actionIndex++)
    {
        var testAction = _testEditInfo.TestCase.Actions[actionIndex];
        if (testAction is ISharedStepReference)
            continue;
    
        var userStep = _testEditInfo.SimpleSteps[actionIndex];
    
        var stepResult = iteration.CreateStepResult(testAction.Id);
        stepResult.ErrorMessage = String.Empty;
        stepResult.Outcome = userStep.Outcome;
    
        foreach (var attachmentPath in userStep.AttachmentPaths)
        {
            var attachment = stepResult.CreateAttachment(attachmentPath);
            stepResult.Attachments.Add(attachment);
        }
    
        iteration.Actions.Add(stepResult);
    }
    
    var overallOutcome = _testEditInfo.SimpleSteps.Any(s => s.Outcome != TestOutcome.Passed)
        ? TestOutcome.Failed
        : TestOutcome.Passed;
    
    iteration.Outcome = overallOutcome;
    
    result.Iterations.Add(iteration);
    
    result.Outcome = overallOutcome;
    result.Save(false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found many tutorials about using Windows Server 2003 as a development machine,
I have found several ways online but none seem to work. Does anyone know
I have searched for examples and found several but they are whole large projects.
I have found several other questions here on S.O. (and the web in general)
I've investigated several C# DLL's and have not found any that work especially well.
I have found some in the Cappuccino website (vim, textmate and SubEthaEdit), but not
I have found a few libraries to edit MP3 tags (UltraID3Lib is great) but
I am seriously confused about the Objective-C #import. I searched and found several tutorials
I have found several sources regarding how to validate an xml document against a
I have found several libraries for XML Parser in OCaml, such as PXP or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.