I'm developing an API in one of my C# library to upload the test result documents (such as log file, screenshots captured or any zip file) from the local folder to the desired test case number under the test plan on Test hub. I'm working with TFS 2018.
Can anyone please help me with the code snippet to implement this functionality.
At present I'm able to establish the connection with the server with the below lines of code:
VssClientCredentials vssClientCred = new VssClientCredentials();
vssClientCred.Storage = new VssClientCredentialStorage();
VssConnection connection = new VssConnection(new Uri("TestHubServerURL"), vssClientCred);
TestManagementHttpClient tManageHttp = connection.GetClient<TestManagementHttpClient>();
TestResultDocument tdoc = new TestResultDocument();
TestResultDocument tRun = tManageHttp.PublishTestResultDocumentAsync(tdoc, ProjectName, TestRunID).Result;
But now I'm stuck, I'm not getting a way to to implement "PublishTestResultDocumentAsync" or do I need to use any other way to implement this functionality?
I tried googling out but didn't get any help with any examples.
Thank you all in advance.
I guess you meant to upload the test result doucuments to the test run result under the Runs tab in Test hub.
You can use
CreateTestRunAttachmentAsyncmethod to upload the test result doucuments to its test run. See below example:If you want to upload the test results document to the result of a specific test case. You can use
CreateTestResultAttachmentAsyncmethod.If you were trying to upload test result documents to the desired test case number under the test plan on Test hub. You probably need to use the
CreateAttachmentAsyncandUpdateWorkItemAsyncmethods inMicrosoft.TeamFoundation.WorkItemTracking.WebApi, since the Test Case is a type of Work Item.