我如何设置黄瓜方案成为setCapability中的testName

  DesiredCapabilities dc = new DesiredCapabilities();

  @BeforeMethod
  public void setUp() throws IOException, InterruptedException {

    dc.setCapability("reportDirectory", reportDirectory);
    dc.setCapability("reportFormat", reportFormat);
    dc.setCapability("testName",cucumberScenario());}


我已经尝试过censing.getName()和scenario.getSourceTagName;
但总是获得空值

最佳答案

在方法参数中添加方案方案。

尝试这个

DesiredCapabilities dc = new DesiredCapabilities();

@BeforeMethod
public void setUp(Scenario scenario) throws IOException, InterruptedException {
dc.setCapability("reportDirectory", reportDirectory);
dc.setCapability("reportFormat", reportFormat);
dc.setCapability("testName",scenario.getName());}

09-30 11:22