Cucumber 中 table.raw 的当前方法是什么

Which is the current method for table.raw in Cucumber

IDEA 不允许我使用 table.raw();

我是 cucumber 的新手,所以当我还是 learning/practising 时,我尝试通过以下代码从 DataTable 获取数据

public void iEnterTheFollowingForLogin(DataTable table) {

    List<List<String>> data = table.raw();
    System.out.println("The value is : "+ data.get(1).get(0).toString());
    System.out.println("The value is : "+ data.get(1).get(1).toString());

}

我意识到 IDEA 以红色键入原始方法,所以我认为它可能已经过时,现在我应该使用更新的方法。

而不是访问原始 table,您可以直接使用 cell(row, column) 寻址单个单元格或使用 cells() 获取列表列表。

import io.cucumber.datatable.DataTable;

import java.util.List;

class Scratch {
    public static void main(String[] args) {
        DataTable data = //...create data table here

        System.out.println("The value is : " + data.cell(1, 0));
        System.out.println("The value is : " + data.cell(1, 1));

        List<List<String>> cells = data.cells();

        System.out.println("The value is : " + cells.get(1).get(0));
        System.out.println("The value is : " + cells.get(1).get(1));

    }
}

只是想详细解释一下MP的回答,方便别人理解- 是的,您将无法再使用 raw() 方法,因为黄瓜 api 不支持新版本的黄瓜,即 io.cucumber。然而,仍然可以将它与旧的 info.cukes 依赖项一起使用。

因此 raw() 的替代方案如 MP 所回答。

对于前者-假设您有以下-小黄瓜步骤示例:

 Then I should see following sections in my app detail page
   |Basic Details|Bank Details|Reconciliation|Summarised Options|Currency Code|
   
 >> The Cucumber step definition for above step should be like belwo-
   
  @Then("I should see following sections in my app detail page")
   public void verifySectionsOnDetailPageUI(List<List<String>> dTable) {

        //Create your table as below (notice- dataTable declared as- List<List<String>> in method argument above)
        DataTable data= DataTable.create(dTable); 
        
        // to get number of rows from DataTable
        int i=data.cells().size(); 
        
        // To print entire row's column (iterate via for loop using size if u have more than one row defined in data table 
        System.out.println("All Cells Data: "+data.cells());
        
        //Read cell by cell data as below, row index to be started from 1 if you have column headings provided in ur table
        
        System.out.println(data.cell(0,0));
        System.out.println(data.cell(0,1));
        System.out.println(data.cell(0,2));
        .....
        ......... so On .. to be used as per your step's objective .....
        
        O/P: 
        
        Basic Details
        Bank Details
        Reconciliation