gpt4 book ai didi

java - org.dbunit.database - junit.framework.ComparisonFailure - 表顺序每次运行都不同

转载 作者:行者123 更新时间:2023-12-02 13:40:33 24 4
gpt4 key购买 nike

运行测试和 table3 的顺序始终不同,因此 AssertEquals 不起作用。

val expectedDataSet = new CsvDataSet(new File(BatchJobIntegrationTest.getTestResource("folder/expected/")))
val actualDataSet = connection.createDataSet(Array(
"table1",
"table2",
"table3"
))

Assertion.assertEquals(expectedDataSet, actualDataSet)

尝试过但没有成功:

Assertion.assertEquals(new SortedDataSet(expectedDataSet), new SortedDataSet(actualDataSet))

最佳答案

事实证明主键是问题所在,这有帮助:

val expectedTable = expectedDataSet.getTable("table")
val actualTable = actualDataSet.getTable("table")

val actualFilteredTable = DefaultColumnFilter.excludedColumnsTable(actualTable, Array("table_id"))
val expectedFilteredTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, Array("table_id"))
//Assertion.assertEquals(expectedTable, actualFilteredTable)

val expectedColumns = expectedFilteredTable.getTableMetaData().getColumns()
val sortedExpected = new SortedTable(expectedFilteredTable, expectedColumns)
val sortedActual = new SortedTable(actualFilteredTable, expectedColumns)
Assertion.assertEquals(sortedExpected, sortedActual)

关于java - org.dbunit.database - junit.framework.ComparisonFailure - 表顺序每次运行都不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42755799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com