reportportal / agent-net-specflow

Report Portal agent for SpecFlow
Apache License 2.0
10 stars 4 forks source link

Example of adding feature description #57

Closed winstondz closed 3 years ago

winstondz commented 4 years ago

I looked through the example agent-net-specflow and I see that the feature description gets added in report portal. Do I have to write something in the customization file or in the hooks for this. If so is there an example? I have both specflow as well as normal nunit tests and if possible want to use just the nunit one (instead of both), but also have the specflow feature description printed? Is this possible with the current implementation?

nvborisenko commented 4 years ago

NUnit agent knows about meta-attributes what nunit engine provides. At the same time specflow generates these attributes. Like for the following feature file

Feature: Calculator
    In order to avoid silly mistakes
    As a math idiot
    I want to be told the sum of two numbers

we get generated csharp class:

[NUnit.Framework.DescriptionAttribute("Calculator")]
public partial class CalculatorFeature
{
}

As we see specflow doesn't put feature description into nunit description. As of one option we can improve generation on the specflow side. Seems this improvement is not so hard to be implemented. So we rely on the future specflow releases with improved code generation.

The second option could be introducing realtime correction of suite description on nunit agent side. It means you will be able to write something like

[Binding]
public sealed class Hooks1
{
  [BeforeFeature]
  public static void BeforeFeature(FeatureContext featureContext)
  {
    ReportPortal.Shared.Context.Current.Metadata.Description += featureContext.FeatureInfo.Description; // or =
  }
}

where ReportPortal.Shared.Context.Current.Metadata.Description is a command for nunit agent to append feature description. This approach is partially implemented, please create separate issue in agent-net-nunit repository.

winstondz commented 4 years ago

Thanks for the detailed explanation! Let me try out the specflow hook approach when I get some time

nvborisenko commented 3 years ago

Closing due inactivity, feel free to reopen.