DB单元应忽略行的顺序 [英] DB Unit should ignore order of rows

查看:158
本文介绍了DB单元应忽略行的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法告诉DB-Unit忽略应该比较行的顺序?我的问题是,我不知道在哪个顺序将行写入数据库,但DB单位强迫我给一个有序的列表。

Is there a way telling DB-Unit to ignore the order in which rows should be compared? My problem is, that I do not know in which order the rows will be written to the database, but DB-Unit forces me to give an ordered list.

想要dbunit做的是:

What I want dbunit to do is:


  • 检查数据库中的行数和预期的数据集是否匹配(解决: >
  • 检查每一行在结果集中是否只有一次。(未解决)

任何想法?

推荐答案

解决这个问题为我排序实际和期望表的行,因此我使用所有列这个方法可能会导致问题,如果你正在检查的表是大的,但在我的情况下不是。: - )

Solved this issue for me. Im sorting the rows of the actual and expected tables. Therefore I use all columns which can be found in expected table. This approach might result in problems if the table you are checking is large but in my case it is not. :-)

Column[] expectedColumns = expectedTable.getTableMetaData().getColumns()
ITable sortedExpected = new SortedTable(expectedTable, expectedColumns);
ITable sortedActual = new SortedTable(actualTable, expectedColumns);
Assertion.assertEquals(sortedExpected, sortedActual);

这篇关于DB单元应忽略行的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆