Search code examples
unit-testingjunitactivejdbc

Unit testing activejdbc code without live database


Any suggestion on how to test activejdbc code without live database? I am unable to follow TDD because at every place it needs a live sql database and I can't mock it. Is having a live sql database for unit testing correct?


Solution

  • ActiveJDBC reads its metadata from the database on the first access. This means that it requires a database. Typically, you would use a different database for testing than the one you use to run the app. Since ActiveJDBC supports multiple databases you can use H2 In-memory database for your tests.

    In any case, what is the purpose of testing ORM classes without a database?