场景大纲动态标题

问题描述 投票:0回答:1

我使用specflow和ReportPortal在c#中使用BDD基础结构。我正在使用场景大纲来自动化相同的流程,有几个参数,但我想在reportPortal中有一个动态标题。一个例子:

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

这种情况不起作用,因为Gherkin不支持场景大纲动态标题。有没有办法可以在以下代码中以某种方式影响方案标题:

        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>();
c# automation specflow gherkin reportportal
1个回答
0
投票

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

您可以订阅ReportPortalAddin.BeforeScenarioStarted事件并修改e.StartTestItemRequest.Name属性。

© www.soinside.com 2019 - 2024. All rights reserved.