reportportal/client-dotnet

TestItem Closing is successfull still getting interrupted error #2141

saurabhsrivastava2009 opened this issue · 3 comments

Hi Team,

We are using C# Report Portal SDK (https://github.com/reportportal/client-net) for reporting test to RP. We have around 1500 cases, which is getting reported to RP and is working as expected, but for some cases the status is coming as interrupted, even when if drilled inside it, it shows as pass as shown in the below screenshot
image

I thought there could be some issue with the closing nested and test item step, so added a try catch, but the issue is still there and the code is not throwing any error.

Below is the code I'm using for adding test item and nested item. Also adding the closing code here

public static async Task<TestItemCreatedResponse> AddTest(LaunchCreatedResponse launchCreatedResponse,
        TestItemCreatedResponse testItemCreatedResponseClass, string description, Status status)
    {
        string testName = "sometest";

        _currentTest = description + "-" + testName;
        TestSetUp.Logger.Log("Current Test :" + _currentTest);
        try
        {
            var testItemTest = await _service.TestItem.StartAsync(testItemCreatedResponseClass.Uuid,
                new StartTestItemRequest
                {
                    LaunchUuid = launchCreatedResponse.Uuid,
                    Name = testName,
                    Type = TestItemType.Step,
                    Description = description,
                    Attributes = new List<ItemAttribute>()
                    {
                        new ItemAttribute { Key = "testCaseName", Value = testName },
                        new ItemAttribute { Key = "reRun", Value = "false" }
                    }
                }
            );
            _testItemTestUuid = testItemTest;
            //for rerun
            if (status.ToString().Equals(Status.Failed.ToString()))
            {
                CustomAPIClass.AddReportPortalItemAndUuid(_currentTest + _productBuildNumber, _testItemTestUuid.Uuid);
            }
        }
        catch (Exception e)
        {
            TestSetUp.Logger.Log("Error is adding test :" + e);
        }

        //Add nested item
        try
        {
            var testItemNested = await _service.TestItem.StartAsync(_testItemTestUuid.Uuid,
                new StartTestItemRequest
                {
                    LaunchUuid = launchCreatedResponse.Uuid,
                    Name = testName,
                    Type = TestItemType.Step,
                    HasStats = false,
                    Description = description
                }
            );
            _testItemNestedUuid = testItemNested;
            if (status.Equals(Status.Failed))
            {
                CustomAPIClass.AddReportPortalItemAndUuid(_currentTest + ":nestedItem" + _productBuildNumber,
                    _testItemNestedUuid.Uuid);
            }
        }
        catch (Exception e)
        {
            TestSetUp.Logger.Log("Error is adding nested step :" + e);
        }


        //close nested item and test item
        await CloseNestedAndTestStep(launchCreatedResponse, _testItemNestedUuid, _testItemTestUuid, status);
        return _testItemNestedUuid;
    }
	
	//close test item and nested item
private static async Task CloseNestedAndTestStep(LaunchCreatedResponse launchCreatedResponse,
        TestItemCreatedResponse testItemCreatedResponseNested, TestItemCreatedResponse testItemCreatedResponseTest,
        Status status)
    {
        try
        {
            await _service.TestItem.FinishAsync(testItemCreatedResponseNested.Uuid, new FinishTestItemRequest
            {
                Status = status,
                LaunchUuid = launchCreatedResponse.Uuid
            });
        }
        catch (Exception e)
        {
            TestSetUp.Logger.Log("Error is closing nested step :" + e);
        }


        try
        {
            await _service.TestItem.FinishAsync(testItemCreatedResponseTest.Uuid, new FinishTestItemRequest
            {
                Status = status,
                LaunchUuid = launchCreatedResponse.Uuid
            });
        }
        catch (Exception e)
        {
            TestSetUp.Logger.Log("Error is closing test item :" + e);
        }
    }

Any

@saurabhsrivastava2009 any logs in your internal Logger?

Hi @nvborisenko
There is no error logged in the logs.. It doesn’t throw any error and it works for most of the testItems but fails for few without any exception. And by fail I mean it shows the status as interrupted in the UI, not on logs

Then you don't finish test item at all.