简体   繁体   中英

Mocking JDBC connection in Scala

I'm trying to test out some Scala code that relies on a JDBC connection to an Oracle database. I would like to setup a mock database and fill it with dummy data to test my code on. I do not want to run a local sql server and am looking for a test framework that will allow me to mock everything so that my code can run on other systems without having to have a local sql server running.

I've looked into JOOQ (need a local sql connection), Acolyte (requires Scala 2.11 and you have to specify every query to be handled), DBUnit (Java only), ScalatestDB (outdated), but have found nothing that suits my needs.

Is there an easy way to mock my entire JDBC connection to test my code in Scala?

Edit: I ended up running an instance of Derby which turned out to be much easier than handling every type of query with Acolyte.

I know that you specifically asked for a test framework, but if you can't find that:

HyperSQL ( http://hsqldb.org ) is a pure Java database which can run in-memory inside of your Java/Scala JVM when running tests. I have used it with great success for something like your use case.

Would not work if there are Oracle-specific features used in the code base you are testing though.

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