How to write test with orm.jar

database

#1

I hope this question is not too amateurish. I am working on a project. I used VP to create mapping, DAO, Criteria… I wrote some functions for CRUD-Operations. Everything works fine.
Then I tried to find a way to writing Integration Test for the program, and I stuck. From what I understand, the best way to test the database is to make some kind of in-memory database, with dbunit or similar. Main point is, the test don’t have to talk to any “real” database. I don’t think I can do that when using any classes, that created by VP(Criteria, DAO), because every session/transaction from these classes always used the hibernate.cfg.xml in the ormmapping folder. And the path to the config file is predefined in orm.jar, which I can’t change.
So my question are:
How can someone write test for database, when using Classes generated by VP?
Do I have to create a database just for testing? Is this a good approach?
Is my initial approach wrong?


#2

Hi,

Visual Paradigm support many DBMS, you can run your test with in-memory/embedded DB like HSQL, H2, SQLite, Derby.
You can also change db configuration at runtime: