2016-08-01 99 views

回答

0

缺少字段被忽略,例如:

static class SomeBean { 
    String field1; 
    String field2; 
    String field3; 

    public SomeBean(String field1, String field2, String field3) { 
     this.field1 = field1; 
     this.field2 = field2; 
     this.field3 = field3; 
    } 
} 

    DataTable expectationBeanTable = DataTable.create(Arrays.asList(
      new SomeBean("value1", "value2", null) 
    )); 

    List<SomeBean> actual = Arrays.asList(
      new SomeBean("value1", "value2", "value3") 
    ); 
    expectationBeanTable.diff(actual); //OK 

    DataTable expectationStringTable = DataTable.create(Arrays.asList(
      Arrays.asList("field1", "field2"), 
      Arrays.asList("value1", "value2") 
    )); 

    expectationStringTable.diff(actual); //Also OK 
比較兩個數據表時,雖然

將不起作用:

expectationStringTable.diff(DataTable.create(actual)); 

java.lang.IllegalArgumentException: Tables must have equal number of columns: 
     | field1 | field2 | 
     | value1 | value2 | 

     | field1 | field2 | field3 | 
     | value1 | value2 | value3 |