Understanding DBUnit Per Record Comparison

Asked 2 years ago, Updated 2 years ago, 149 views

Thank you for your continuous support.

I'm struggling with how to use DBUnit, so I'd like to ask for your advice.

You can compare the actual table with the data specified in Excel in DBUnit, but
Is it possible to retrieve and compare the specified records from the real table?

★How to compare the actual table in DBUnit with the data specified in Excel

IDataSet databaseDataSet=connection.createDataSet();

    // Retrieving actual data from DB
    ITable actualTable=databaseDataSet.getTable("M_KEIYAKU");

    // acquisition of expected value data
    IDataSet expectedDataSet=newXlsDataSet(
            new File("src/M_TEST.xlsx"));
    ITable expectedTable=expectedDataSet.getTable("M_KEIYAKU");


    // Comparison of expectations and actual data
    Assertion.assertEquals (expectedTable, actualTable);

Why do you want to do it?
  
when performing multiple test patterns   At the end of each test, the test data was deleted and the data was consistent.   I'd like to check the data after the test.

java junit

2022-09-30 21:10

1 Answers

Now I know how to implement it.

https://www.ibm.com/developerworks/jp/java/library/j-dbunit/
List 2.DbUnit Query Capabilities


2022-09-30 21:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.