How to get test case execution of a test case with context of a Test Suite..?? if the same test case is present in another test suite, I do not want it, its information is irrelevant to me.
I am using the code, but it is not behaved as expected.
I have also attached the expected output (image).(there are 2 test results present and it is correct)
By using the code, what I get, is also attached in json format, and it is not matched with the expected output. (I get only 1 test result)
Kindly help me out, thanks in advance.
using System;
// Assembly Microsoft.TeamFoundationServer.Client.16.205.1\lib\net462\Microsoft.TeamFoundation.TestManagement.WebApi.dll
using TFSRestApi = Microsoft.TeamFoundation.TestManagement.WebApi;
public class QueryRunner
{
private void GetTestResultByPointId()
{
try
{
TFSRestApi.TestResultsQuery query = new TFSRestApi.TestResultsQuery();
TFSRestApi.ResultsFilter filter = new TFSRestApi.ResultsFilter();
//manual test so I set to empty string
filter.AutomatedTestName = "";
//test case id
filter.TestCaseId = 1109;
List<int> pointIds = new List<int>();
//list of test point ids
pointIds.Add(1974);
filter.TestPointIds = pointIds;
//set plan id to 1 b/c do not have plan id, i think it is not mandatory at all
filter.TestPlanId = 1;
filter.TestResultsContext = new TFSRestApi.TestResultsContext();
query.ResultsFilter = filter;
TestMRHttpClient testManagementHttpClient = new TestMRHttpClient(new Uri("https://dev.azure.com/abc/"), new VssOAuthAccessTokenCredential("extensionToken"));
TFSRestApi.TestResultsQuery result = testManagementHttpClient.GetTestResultsByQueryAsync(query, "Project G").Result;
}
catch (Exception e)
{
DebugLogger.LogError(e);
}
}
}
public class TestMRHttpClient : TestHttpClientBase
{
public TestMRHttpClient(Uri baseUrl, VssCredentials credentials)
: base(baseUrl, credentials)
{
// Add the body of the constructor here.
}
}
{
"Results": [
{
"BuildReference": {
"DefinitionId": 0,
"Id": 0,
"Number": "0"
},
"CompletedDate": "\/Date(1692709425060)\/",
"Configuration": { "Id": "11" },
"CreatedDate": "\/Date(1692709419570)\/",
"DurationInMs": 5460,
"FailureType": "None",
"Id": 100000,
"LastUpdatedBy": "<IdentityRef xmlns=\"schemas.datacontract.org\/2004\/07\/Microsoft.VisualStudio.Services.WebApi\"><Descriptor>aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/Descriptor><DisplayName>Muhammad Jalees<\/DisplayName><Url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/Url><displayName>Muhammad Jalees<\/displayName><DisplayName>Muhammad Jalees<\/DisplayName><id>fb30a18d-589c-64da-9a39-48d8889faec1<\/id><Id>fb30a18d-589c-64da-9a39-48d8889faec1<\/Id><imageUrl>_apis\/GraphProfile\/MemberAvatars\/aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/imageUrl><ImageUrl>_apis\/GraphProfile\/MemberAvatars\/aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/ImageUrl><uniqueName><\/uniqueName><UniqueName><\/UniqueName><url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/url><Url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/Url><\/IdentityRef>",
"LastUpdatedDate": "\/Date(1692709427647)\/",
"Outcome": "Passed",
"Owner": "<IdentityRef xmlns=\"schemas.datacontract.org\/2004\/07\/Microsoft.VisualStudio.Services.WebApi\"><Descriptor>aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/Descriptor><DisplayName>Muhammad Jalees<\/DisplayName><Url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/Url><displayName>Muhammad Jalees<\/displayName><DisplayName>Muhammad Jalees<\/DisplayName><id>fb30a18d-589c-64da-9a39-48d8889faec1<\/id><Id>fb30a18d-589c-64da-9a39-48d8889faec1<\/Id><imageUrl>_apis\/GraphProfile\/MemberAvatars\/aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/imageUrl><ImageUrl>_apis\/GraphProfile\/MemberAvatars\/aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/ImageUrl><uniqueName><\/uniqueName><UniqueName><\/UniqueName><url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/url><Url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/Url><\/IdentityRef>",
"Priority": 2,
"Project": { "Id": "120ed16c-aa74-4049-ba94-90d8ef02a64c" },
"Revision": 3,
"RunBy": "<IdentityRef xmlns=\"schemas.datacontract.org\/2004\/07\/Microsoft.VisualStudio.Services.WebApi\"><Descriptor>aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/Descriptor><DisplayName>Muhammad Jalees<\/DisplayName><Url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/Url><displayName>Muhammad Jalees<\/displayName><DisplayName>Muhammad Jalees<\/DisplayName><id>fb30a18d-589c-64da-9a39-48d8889faec1<\/id><Id>fb30a18d-589c-64da-9a39-48d8889faec1<\/Id><imageUrl>_apis\/GraphProfile\/MemberAvatars\/aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/imageUrl><ImageUrl>_apis\/GraphProfile\/MemberAvatars\/aad.ZmIzMGExOGQtNTg5Yy03NGRhLTlhMzktNDhkODg4OWZhZWMx<\/ImageUrl><uniqueName><\/uniqueName><UniqueName><\/UniqueName><url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/url><Url>spsprodsin2.vssps\/Ab70c43dc-f213-4dda-b2a9-1d4777eeb08f\/_apis\/Identities\/fb30a18d-589c-64da-9a39-48d8889faec1<\/Url><\/IdentityRef>",
"StartedDate": "\/Date(1692709419600)\/",
"State": "Completed",
"TestCase": {
"Id": "1109",
"Name": "tc 3"
},
"TestCaseReferenceId": 666611,
"TestCaseRevision": 1,
"TestCaseTitle": "tc 3",
"TestPlan": { "Id": "1" },
"TestPoint": { "Id": "1974" },
"TestRun": {
"Id": "91",
"Name": "New Suite 4 (Manual)"
}
}
],
"ResultsFilter": {
"AutomatedTestName": "",
"TestCaseId": 1109,
"TestPlanId": 1,
"TestPointIds": [ 1974 ],
"TestResultsContext": {
"Build": null,
"ContextType": 0,
"PipelineReference": null,
"Release": null
}
}
}