According to Points - Update from Microsoft's own documentation, in api ver 7.1, we can assign testers to test points by updating test point like:
with example request body:
{ "tester": { "displayName": "Jamal Hartnett" } }
However when I do so for my selected test point while using parameter uniqueName, I get the following error (please note the helpful message I get back):
{
"$id": "1",
"innerException": null,
"message": "Tester",
"typeName": "System.ArgumentException, mscorlib",
"typeKey": "ArgumentException",
"errorCode": 0,
"eventId": 0
}
So my question is: how can I assign the tester to a test point in Azure DevOps via API call? Documentation also notes that uniqueName is deprecated - and suggests to use Domain+PrincipalName instead. But as what - as uniqueName? As another key/parameter? What is PrincipalName? What format should the new value be in?
I know that authorization, headers & parameters are set correctly, as I re-use same base methods to extract test suites from a test plan, then test cases, then create test points by assigning configurations to them. The only step that fails is this tester assignment. I use RestAssured with Java and build my JSONs as POJOs.
My code - please note that in RA, query parameters are added via methods queryParam & queryParams instead of adding them at the end of the path with ? (also sorry for weird values, had to anonymize data):
PATCH Request Base URI: https://dev.azure.com
PATCH Request Base PATH: /organizationName/projectName/_apis/test/Plans/111111/Suites/222222/points/333333
My Json:
{"tester":{"uniqueName":"email.thatisunique@companydomain.com"}} // I use company emails, value that populates this field for other TCs
Headers:
Connection=keep-alive
Accept-Encoding=gzip,deflate
Accept=text/xml;charset=UTF-8
Accept=application/json
X-XSS-Protection=1; mode=block
Params:
{api-version=7.1}
Request code:
protected Response sendPatchRequest(Object serializedPojo, int expectedStatusCode) {
// setup
RestAssured.baseURI = baseURI;
RestAssured.basePath = basePath;
// logs
String payloadAsString = objectMapper.writeValueAsString(serializedPojo);
LogsHelper.log("PATCH Request payload: " + System.lineSeparator() + payloadAsString + "--------------------------------------");
LogsHelper.log("PATCH Request Base URI: " + baseURI);
LogsHelper.log("PATCH Request Base PATH: " + basePath);
LogsHelper.log("PATCH Request Headers list: " + getHeaders().toString());
// request
ExtractableResponse<Response> extract = RestAssured
.given()
.queryParams(params)
.relaxedHTTPSValidation()
.headers(headers)
.body(serializedPojo)
.contentType("application/json")
.when()
.patch()
.then()
.extract();
try {
assertEquals("Status code not equal " + expectedStatusCode, expectedStatusCode, extract.response().getStatusCode());
} catch (AssertionError e) {
LogsHelper.log("PATCH Request response: " + System.lineSeparator() + extract.response().prettyPrint());
}
return extract.response();
}
I posted the same question on VS developer community forum and got the following answer:
Thanks for your time and wish you a good day!
During my discussion with our internal resources, we confirm that for the current time it’s suggested that we should use displayName and ID in this API. And as UniqueName is deprecated, we should not use it in our workflow.
We have reported this situation to our related team for further evaluations. And for this current time, we will close this ticket as this is not a bug.
Thanks for your understandings, and we’d recommend you to come back to this community if you meet any issues related to Azure DevOps.
We will still be here to help you solve issues. Thank you for helping us build a better Azure DevOps.
So, currently you can assign tester using displayName
and id
only.
Id can be retrieved with this method:
GET https://vsaex.dev.azure.com/{organization}/_apis/memberentitlements?continuationToken={continuationToken}&select={select}&$filter={$filter}&$orderBy={$orderBy}&api-version=7.1-preview.2
or by manually assigning tester to a test point and then getting the id from test point details with this request:
GET https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/{planId}/Suites/{suiteId}/TestPoint?pointId={pointId}&api-version=7.1