reportportal / agent-net-nunit

Report Portal integration point with NUnit 3
Apache License 2.0
21 stars 10 forks source link

Attributes are not posted to the Launch or Test using customization class #63

Closed winstondz closed 4 years ago

winstondz commented 4 years ago

I am unable to post attributes using the customization example (https://github.com/reportportal/example-net-nunit/blob/master/src/Example/ReportPortalCustomization/Customization.cs) to Report Portal. The attributes can be successfully added using the json configuration file, but not through the code. I tried the following sample methods.

private void ReportPortalListener_BeforeRunStarted(object sender, RunStartedEventArgs e)
{
    // add custom attributes
    e.StartLaunchRequest.Attributes.Add(new ItemAttribute { Value = "test_tag" });           
}

private void ReportPortalListener_AfterTestStarted(object sender, TestItemStartedEventArgs e)
{
    e.StartTestItemRequest.Attributes.Add(new ItemAttribute { Value = "test_tag" });
}

I am able to modify the test name and other modifications using the BeforeRunStarted methods, but the attributes functionality does not work

Report Portal - [Current version:API Service: 5.2.1;Index Service: 5.0.7;Authorization Service: 5.2.1;Service UI: 5.2.0]

image

nvborisenko commented 4 years ago

Please share ReportPortal.*.log files.

winstondz commented 4 years ago

Apologies ! I forgot to update the ctor() in the customization class. Now I see all the messages. I did check the logs and see

ReportPortalListener Error: 0 : 11:42:52.6471459 : 1-testhost.x86.exe : Exception was thrown in 'BeforeSuiteStarted' subscriber. System.NullReferenceException: Object reference not set to an instance of an object.

which led me to identify the issue.

You were right about the test context not working (even with the inprocess tag in nunit console) . I will wait for the feature which gives the ability to add attributes through the Shared logs (https://github.com/reportportal/commons-net/issues/46)