TestItem Attribute value is coming as empty
saurabhsrivastava2009 opened this issue · 4 comments
Hi Team,
I have added a attribute in my testItem but while fetching the current value for that attribute, it is coming as empty, although I can see the value in the UI.
Here is the code I'm using to get the attribute value
private static async Task<Dictionary<string, Status>> GetHistory(string testItemCreatedResponseTest,
String currentTest)
{
int position = 1;
Dictionary<string, Status> testStatusCollection = new Dictionary<string, Status>();
var response = await _service.TestItem.GetAsync(testItemCreatedResponseTest);
var history = await _service.TestItem.GetHistoryAsync(response.Id, 5);
var testItemHistoryElements = history.Items.First().Resources;
foreach (var testItemHistoryElement in testItemHistoryElements)
{
var status = testItemHistoryElement.Status;
string key = currentTest + "#" + position;
testStatusCollection.Add(key, status);
position++;
foreach (var testItemResponse in testItemHistoryElement.Resources)
{
foreach (var testItemAttribute in testItemResponse.Attributes)
{
TestSetUp.Logger.Log("testItem Attributes:"+testItemAttribute.Key+":"+testItemAttribute.Value); **//This is also not getting printed, seems like a issue with loop**
if (string.Equals(testItemAttribute.Key.ToString(), "stabilityScore", StringComparison.OrdinalIgnoreCase))
{
_lastStability = testItemAttribute.Value; **//This is the value I'm trying to get**
break;
}
}
break;
}
}
foreach (var keyValuePair in testStatusCollection)
{
TestSetUp.Logger.Log("History for the test:(" + keyValuePair.Key + "," + keyValuePair.Value + ")");
}
return testStatusCollection;
}
private static async Task<double> GetStabilityScore(Dictionary<string, Status> testStatusCollection, string testItemCreatedResponseTest)
{
//Test specific variables
int totalRunCount = testStatusCollection.Count;
int failedCount = testStatusCollection.Values.Count(status => status == Status.Failed);
int passCount = testStatusCollection.Values.Count(status => status == Status.Passed);
//var lastStabilityScore = await GetLastStabilityScore(testItemCreatedResponseTest);
TestSetUp.Logger.Log("Last Stability =" + _lastStability);
return _actualStability;
}
Logs
2023-10-25 18:47:25.436 | 10/25/2023 6:17 AM client_version="27.0.0.0" flow_id="150fb7577c044eebbba85f777a4b426a" method="GetStabilityScore" - Last Stability =
Is this the correct way to get the attribute value?
@nvborisenko is this change pushed to the artifactory? I may need to use the updated nuget version? and How do we get the testItem attribute value now?
@nvborisenko The version I'm using is 4.6.0, why pushed to a old version?
<PackageReference Include="ReportPortal.NUnit" Version="4.6.0" />