简体   繁体   中英

Embedded Database for Junit Tests for non-spring application

I am looking for a embedded database which I can use in JUnit 4.12 tests. Because of the current nature of our code base & time-lines it is not possible for us to mock the database calls. We are concerned only about Mysql database. So I am looking for some kind of Embedded database which I can initialize before our each test run & then clear it after the tests. Some what similar to what wiremock does for http server.

I have gone through this & it seems it is possible to achieve it via H2 embedded database. Most of the links I have found in the web talks about using it with Spring.

Can some one let me know

  1. If it is possible to achieve the same using H2 as embedded database for Junit tests for non-spring application? If yes can someone let me know how to do this or point me to some link where this use case is explained?
  2. Also is there some other tools other than H2 which I can use to achieve my goals?

I think you can use H2, but I prefer to use hsqldb for this purpose. I need some embedded db which can imitate some oracle-specific features in sql. From my best knowledge you can use any embedded java database for unit testing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM