I want to test my orm-part of my web application written in java-jpa. When there is the test goal of maven running, the creating tables in database didn’t trigger yet, because the app is not deployed on the server yet. Is there a way, how can I test this? When I say test, I mean for example do some persisting then some queriyng, check the results are OK, then continue. I think it’s probably better than typing it by and hand everytime…
Share
It is independent of Maven but DBUnit will provide all you need for database testing and will run as part of junit tests.
See:
http://www.dbunit.org/howto.html
Also useful for this are running the tests intransactions os the database is left in the same state after the test. Spring provides some nice ways of acheiving this. See here:
9.3.5.4 Transaction management – at http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/testing.html#testing-tx