reportportal/client-dotnet

[Could be a Bug] Could not get the actual ID from the below code

saurabhsrivastava2009 opened this issue · 5 comments

Hi Team,

I was trying to update a test item using the below code, but I was not able to get the actual ID.
https://github.com/reportportal/client-net/blob/e32d461ec035c79bfcdeca1197ab48f463c0a30a/test/ReportPortal.Client.IntegrationTests/TestItem/UpdateTestItemFixture.cs#L151C15-L151C15

Then I updated the code with
await Service.TestItem.UpdateAsync(tempTest.Result.Id, updateRequest);
instead of
await Service.TestItem.UpdateAsync(tempTest.Id, updateRequest);

Is this change expected? Because the 1st line of code works for me and is updating the test case.

@saurabhsrivastava2009 please provide full context of the code you use. The code in examples works for all users, may be you use the library wrong?

@nvborisenko
This is the code I'm using

private static ReportPortal.Client.Service _service = new ReportPortal.Client.Service(
        new Uri(Environment.GetEnvironmentVariable("REPORT_PORTAL_URI")),
        Environment.GetEnvironmentVariable("REPORT_PORTAL_DASHBOARD_PROJECT"),
        Environment.GetEnvironmentVariable("REPORT_PORTAL_API_KEY"));

//some more code
//
//
public static async Task UpdateTest(string description, Status status, string rerun, string failureMessage = "",
        string stacktrace = "")
    {
string requiredUuid = await Helper.GetUuidForReportPortalItem(_currentTest + _productBuildNumber);

var updateItem = _service.TestItem.GetAsync(requiredUuid);

var updateAsync = _service.TestItem.UpdateAsync(updateItem.Result.Id, new UpdateTestItemRequest
                {
                    Status = status,
                    Attributes = new List<ItemAttribute>()
                    {
                        new ItemAttribute { Key = "testCaseName", Value = testName },
                        new ItemAttribute { Key = "className", Value = onlyClassName },
                        new ItemAttribute { Key = "reRun", Value = "true" }
                    }
                });
TestSetUp.Logger.Log("Update Done for:" + updateItem.Result.Id + " with message:" +
                                     updateAsync.Result.Info);
}

And what exactly doesn't work? Any exceptions raised during code execution?

As per the example given in the repo, we should be using updateItem.Id, but this returns single digit number for that run, like 1-N. When I use updateItem.Result.Id, i get the actual Uuid.

So the confusion here, which one is correct and Result.Id works for me, but you mentioned, only Id works too for other users.

You don't await async method:

var updateItem = _service.TestItem.GetAsync(requiredUuid);