我使用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>();
您可以订阅ReportPortalAddin.BeforeScenarioStarted
事件并修改e.StartTestItemRequest.Name
属性。