Blog Archive for April 1, 2020

Using H2 in Spring Tests

April 1, 2020

Rather then mock out my database layer code I decided to use the H2 in memory database to effectively provide a mock database implementation, where SQL would work as expected.

For unit tests, this can be done using an annotation:

package com.drumcoder.diary.test.service …