TFS - Running a testcase from C# using REST-API

Gooly 21 Reputation points

Hi all,

I'm building a custom TFS client application which is supposed to locate a test case by it's name.
Create a new Run for that test , execute the Run step by step (I'd like to have access to each single step), log actual results (versus the expected results) and Pass/Fail the test run at the end.

Are these steps supported ? If so, how ? (code samples will be most welcome).


An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,237 questions
{count} votes

Accepted answer
  1. Jack J Jun 23,816 Reputation points Microsoft Vendor

    @Gooly , based on my test, you could try to install nuget-package Microsoft.TeamFoundationServer.Client to use the code in Github.

    Also, I noticed that there is a compile error in the code after I add the package.

    You could make changes in the following code. (just add two null parameters otherwise it will cause conflict between classes)

      var attachmentObject = _witClient.CreateAttachmentAsync(uploadStream, "Canvas.png", "Simple",null,null).Result;  

    Update for the steps that how to use the nuget-package without internet.

    First, Please download the nuget-package from the link Microsoft.TeamFoundationServer.Client in the another computer.


    Second, after the downloading, you will get a NUPKG file and copy it to the no-internet computer.

    Third, you could create a folder and copy the NUPKG file to the folder, like the following:

    Fourth, Please open your project and open the nuget-package.

    Fifth, Please click theGears

    Sixth, Please click '+' , set the source of the nuget and click update and ok.


    Finally, you could choose Package source and install the nuget-package.


    Hope this could help you.

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Dave Patrick 354.1K Reputation points MVP

    The product group for Azure DevOps / TFS actively monitors questions over at

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    1 person found this answer helpful.