views:

35

answers:

0

Hi,

Following is a test case which tests the working of org.dbunit.Assertion.assertEquals(ITable a, ITable b)

@Test
public void testAssertion() {
    try {
        //Creating actual table with 2 columns
        DefaultTable actual = new DefaultTable("table_name",
                new Column[] { new Column("col1", DataType.INTEGER),
                        new Column("col2", DataType.VARCHAR) });
        actual.addRow(new Object[] { 1, "ABCD" });
        actual.addRow(new Object[] { 2, "BABCD" });
        actual.addRow(new Object[] { 3, "CCGF" });

        //Creating expected table with same 2 columns
        DefaultTable expected = new DefaultTable(expected
                .getTableMetaData());
        expected.addRow(new Object[] { 1, "ABCD" });
        expected.addRow(new Object[] { 2, "BBCD" });

        // Check the actual vs expected
        Assertion.assertEquals(actual, expected);
        //This should return a test failure since actual & expected are different.
        //But its not throwing any test case failure.
    } catch (DataSetException e1) {
        e1.printStackTrace();
    } catch (DatabaseUnitException e) {
        e.printStackTrace();
    }
}

Here both the DefaultTable's values are mismatched and still JUnit is not failing the above testcase. I am running it from the eclipse and it results in 0 Errors and 0 Failures with an Unrooted Tests under the testcase like as follows,

    testAssertion [Runner: JUnit 4]
[+] Unrooted Tests [Runner: JUnit 4]

I debugged the DBUnit API and it is throwing data mismatch exception as required, but finally when returning from SpringJUnit4ClassRunner it is not thrown as a test case failure.

I suppose something I am missing here. Pls correct me or let me know a solution for this. Thanks in advace.