运行测试和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))
答案 0 :(得分:1)
原来关键是问题,这有助于:
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)