SQL Server tSQLt - How does AssertEqualsTable work?

wztqucjr  于 2023-05-28  发布在  其他
关注(0)|答案(1)|浏览(119)

tSQLt has a command called AssertEqualsTable that tests whether contents of 2 tables match.

I would like to understand how the logic works, does it use the first column as a JOIN between the 2 tables, to then test whether the rest of the columns for that row (join) match?

ni65a41a

ni65a41a1#

AssertEqualsTable compares the whole row - i.e. all columns. For example if the expected table has one row of four columns ('A', 'B', 'C', 'D') and actual also has one row ('A', 'B', 'C', 'E'), the result returned by AssertEqualsTable will show two rows - the ABCD row expected not found plus the ABCE row returned but NOT expected.

There is is no guarantee that the expected and actual tables in every single test that anyone might want to write would even have a unique key so the comparison has to be based on the whole row.

相关问题