How to Automate Tests for Spring Boot API using MockServer

Test your APIs with MockServer like a real service

Gavin F.
8 min readJul 26, 2021
Photo by Pablo Merchán Montes on Unsplash

System integration is inevitable as part of application development. Whether your system is a set of modern microservices or a legacy monolithic system, most system logic depends on other processes or data sources in order to deliver meaningful business functions. The integration would be in the form of library function calls or REST API calls. Interfacing with other components is often a headache, especially when your counterparts are not available for testing during the system development. It is a constraint to the quality assurance on the interfacing logic. As a result, a number of system bugs would be discovered in the later stage of the development cycle and possibly hinder the progress of system delivery.

For a long time, developers have been struggling with this problem. In the old days, a certain amount of development effort was planned in every new development project to build stubs which emulates the responses of external services so that the development and testing can be carried out in absence of those dependencies.

For example, people built an adapter in the interfacing component that reads mock data responses from an “offline” file. Such an adapter is not a dummy stub, the development is a time…

--

--

Gavin F.

Decades experience in software development. Building software and researching technologies are my full-blown obsession.