title: How to create a test run and result using the Team Foundation Server API?
body: <p>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?</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>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];
  }
  </code></pre>
  
  <p>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.</p>