mardi 5 avril 2016

Unit Test for a method that returns a Connection object

I have implemented a method that returns a Connection object.

Now I want to unit test that method and when I make the typical

assertEquals(expectedConnection, actualConnection);

it fails with the error code:

java.lang.AssertionError: expected [org.sqlite.SQLiteConnection@1a968a59] but found [org.sqlite.SQLiteConnection@4667ae56]

I hoped the test passed as, even when the objects are not the same (that's why I haven't used assertSame), they have the same characteristics (have been built in the same way, with the same class atributes)... Is there any way to test Connection objects?

NB: I have the same issue with the unit test of a method that returns a statement

Thanks for your help!!

Aucun commentaire:

Enregistrer un commentaire