【问题标题】:Scenario Outline Dynamic title场景大纲动态标题
【发布时间】:2019-02-21 10:02:00
【问题描述】:

我使用 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】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-09-01
      • 1970-01-01
      • 2020-07-11
      • 1970-01-01
      • 1970-01-01
      • 2014-10-12
      • 2021-04-29
      • 1970-01-01
      • 2018-03-10
      相关资源
      最近更新 更多