0
votes

I work on BDD infrastructure in c# using specflow, and ReportPortal. I am using scenario outline in order to automated the same flow, with several parameters, but I want to have a dynamic title in reportPortal. an example:

Scenario Outline: Perform a Test on car <car model>
Given I have the car"<car>"
When I expect that "<car>" has 4 wheels
Then I expect that the car will be able to move

This scenario doesn't work, since Gherkin doesnt support in scenario outline dynamic title. Is there a way where I can somehow influence the scenario title in the following code:

        var currentFeature = FeatureContext.Current;
        var currentScenario = ScenarioContext.Current;
        var jsonRootElement = (JsonReportRootObject)currentFeature["JsonReport"];
        var scenarioElement = new Element();
        scenarioElement.keyword = "Scenario";
        scenarioElement.line = 0;
        scenarioElement.name = currentScenario.ScenarioInfo.Title;
        scenarioElement.steps = new List<Step>();
1

1 Answers

1
votes

https://github.com/reportportal/example-net-specflow/blob/master/src/Example.SpecFlow/Hooks/Hooks1.cs

You can subscribe on ReportPortalAddin.BeforeScenarioStarted event and modify e.StartTestItemRequest.Name property.