Class DataTables

java.lang.Object
com.tngtech.jgiven.DataTables

public class DataTables extends Object
A utility class to create data tables.
  • Constructor Details

    • DataTables

      public DataTables()
  • Method Details

    • table

      public static Iterable<? extends Iterable<?>> table(int numberOfColumns, Object... data)
      Creates a table, i.e. a list of lists, with numberOfColumns columns from the given data including the header.

      Example:

      
           table(2,
              "name", "age", // header
              "Peter", 20,   // first row of data
              "Susan", 35);  // second row of data
       
      Parameters:
      numberOfColumns - the number of columns the resulting table should have
      data - the data of the table represented as a one-dimensional list, the number of entries must be a multiple of numberOfColumns. The first numberOfColumns elements are taken as the header of the table, the remaining values as data
      Returns:
      a list of list that contains the same data as data, but in a two-dimensional form
      Throws:
      IllegalArgumentException - if data.length % numberOfColumns != 0