0

I've created a test run with test points, is there a way to mark failed/ passed on one of the test inside the test run using the Api?

public ITestRun createRun(ITestPlan tfsPlan, IEnumerable<ITestPoint> points)
        {
            ITestRun run = tfsPlan.CreateTestRun(true);
            foreach (ITestPoint tp in points)
            {
                run.AddTestPoint(tp, null);
            }
            run.Save();
            ITestCaseResult result = run.QueryResults()[0];
            result.Outcome = TestOutcome.Failed;               
            return run;
        }

this is my method but it's not work. Thank you helping me :-)

k.diallo
  • 11
  • 5

1 Answers1

0

For .net api, you may check this case: How to create a test run and result using the Team Foundation Server API?

Instead of .net api, you can consider using REST API:

POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}

Content-Type: application/json

{
  "index": {int},
  "testCaseTitle": { string },
  "testCase": {
    "id": { int }
  },
  "configuration": {
    "id": { int },
    "name": {string }
  },
  "testPoint": {
    "id": { int }
  },
  "state": {
    enum { Pending, Queued, InProgress, Paused, Completed }
  },
  "computerName": { string },
  "resolutionState": { string },
  "testCasePriority": { string },
  "failureType": { string },
  "automatedTestName": { string },
  "automatedTestStorage": { string },
  "automatedTestType": { string },
  "automatedTestTypeId": { string },
  "automatedTestId": { string },
  "area": {
    "name": {string}
  },
  "owner": {
   "DisplayName": {string}
  },
  "runBy": {
   "DisplayName": {string}
  },
  "outcome": {
        enum { None, Passed, Failed, Inconclusive, Timeout, Aborted, Blocked, NotExecuted, Warning, Error, NotApplicable, Paused, InProgress}
  },
  "errorMessage": { string },
  "comment": { string },
  "startedDate": { DateTime },
  "completedDate": { DateTime },
  "durationInMs": { long },
  "associatedWorkItems": [ 
    { int } 
  ]
}
Community
  • 1
  • 1
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39