问题1,table assertion时报column数目不统一的错误,日志如下:
junit.framework.ComparisonFailure: column count (table=mytable, expectedColCount=25, actualColCount=24) expected:<...COL1, COL2, [COL3, ]COL4, COL5...> but was:<...COL1, COL2, []COL4, COL5...>
解决方法:
导致该问题的原因一般是我们的数据库表expecttable与目标表actualtable的列数目不统一(因为actualtable中会把null值的列也加入列总数)
可利用DefaultColumnFilter从actualtable中过滤出expecttable的列,然后用该结果和expecttable比较
代码如下:
ITable filteredTable = DefaultColumnFilter.includedColumnsTable(actual,expected.getTableMetaData().getColumns());
Assertion.assertEquals(expected, filteredTable);
参考:
http://ds.cc.yamaguchi-u.ac.jp/~joji/doc/dbunit/howto.html#compareignorecolumns
https://gist.github.com/VineetReynolds/3885719