【问题标题】:Print Data tables of Cucumber Java on terminal/console在终端/控制台上打印 Cucumber Java 的数据表
【发布时间】:2016-11-03 21:27:22
【问题描述】:

我正在尝试使用包含一些数据表的步骤定义创建一些场景Cucumber Data Tables

我的测试正确执行,我在控制台/终端上打印了场景和步骤定义,但不是数据表。在 Ruby 中,所有数据表都与 Scenarios 和 Steps 定义一起打印,但在 Java 中没有

我正在使用 Maven。我用以下方式调用测试场景:

@RunWith(Cucumber.class)
@CucumberOptions(features="pathtoFeatureFile.feature" ,plugin = { "pretty" }, monochrome = true)

谢谢

【问题讨论】:

  • 您找到解决方案了吗?

标签: java eclipse automation cucumber cucumber-jvm


【解决方案1】:

使用DataTable的toString()方法或直接使用System.out.println()中的dataTable变量,将Feature File中定义的DataTable原样打印出来

    public void the_board_should_look_like_this(DataTable expectedTable) throws Throwable {
        System.out.println("Printing Datatable : \n"+expectedTable.toString());
        expectedTable.diff(board);
    }


public void the_board_should_look_like_this(DataTable expectedTable) throws Throwable {
    System.out.println("Printing Datatable : \n"+expectedTable);
    expectedTable.diff(board);
}

【讨论】:

  • 这会在与场景不同的时间打印数据表。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-22
  • 1970-01-01
  • 2016-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多