0

我使用 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>();
4

1 回答 1

1

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

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

于 2019-03-11T16:00:44.890 回答