3 In-Memory Database Usage Strategy for Spring Boot Integration Test

Susanta Mondal
3 min readAug 21, 2021

Abstract

Having integration test is always a good practice to have when you write your Spring Boot micro-services. Primary objective is to test each functionality of our code without using any mocking framework at integration test stage. There are few options available in open source community to use in-memory database instead of using a real one to facilitate this need.

In this article we are going to look at 3 easy-to-use in-memory database approach for our Spring Boot application testing.

We we will be using Postgres database for this illustration but the same concept can be extended to other supported databases as well.

Setup

Here is the simple project structure of a typical Spring Boot application for micro-service.

Simple Project Structure

The Spring Boot Application Class

package com.example.demo;

import org.springframework.boot.SpringApplication;
import…

--

--

Susanta Mondal

Full-stack architect with 20+ years of experience in various Java related frameworks, Microservices & Cloud. Follow - https://www.linkedin.com/in/susmon