Spring Microservices development following the TDD approach.

TDD of Spring Boot REST (Microservice)

Introduction & Isolated testing of Controllers: -
Java enterprise application in spring
A typical Spring Web application will have the below layers.



Case Study:-

Lets build a small project "Customer Management Service" which has 2 microservices provides operations for registering, viewing, deleting and updating Customer details.

  1. CustomerService: - provides operations for register, view, delete and update of customer details.
  2. ExtService: - validates and confirms if the ssn# details are correct or not.



Both the microservices follows tiered architecture i.e. 
The rest calls are processed from the Controller-Service-Repository(persistent) layer.


Let's design the High-level view of customer microservice.



Spring boot Testing: -

Let us first write the unit tests that can run in isolation and then we will see integration tests that will bootstrap Spring context before executing tests. So we will do 
  1. Isolated testing of Controllers.
  2. Isolated testing of Service Layers.
  3. Isolated testing of Repository Layers.