Software Design

Testing Java Spring Boot Microservices

Testing Java Spring Boot Microservices

Tests are an essential part of any codebase. At a minimum, they help prevent regressions as the code evolves. But not all tests are created equal — unit, integration, component, contract, and end-to-end tests each serve a distinct purpose.

This article presents a practical strategy for testing Java Spring Boot microservices, covering the role, scope, and tooling for each test type to help you make the most of your test suite.

Continue reading
How to Write Robust Component Tests

How to Write Robust Component Tests

Component tests check full use cases from start to finish. They’re essential for verifying and documenting how an application or service behaves overall. But they can be expensive, especially in terms of setup and execution time — which is why it’s important to define their scope carefully.

That said, I’ve often found them cost-effective in distributed architectures. They’re usually simple to set up since you can reuse the service’s external API without needing extras like fake servers. And since each microservice tends to have a narrow focus, you can test behavior thoroughly in isolation.

This article explores how to make component tests more robust — with one key idea: keep them independent of implementation details.

Continue reading
Setup a Circuit Breaker with Hystrix, Feign Client and Spring Boot

Setup a Circuit Breaker with Hystrix, Feign Client and Spring Boot

In a microservices architecture, many things can go wrong: middleware can fail, the network may be unstable, or the service you’re calling might be down. In this uncertain environment, anticipating failures is crucial to prevent breaking the entire chain and delivering errors to the end user—when you could instead offer a partially degraded experience.

This article explains how to implement the circuit breaker pattern using Hystrix, Feign Client, and Spring Boot.

Continue reading
Refactoring Conditional Structures with Map

Refactoring Conditional Structures with Map

I often come across code snippets like this:

public class Day {
  public void start(Weather weather) {
    switch(weather) {
      case RAINY:
          takeAnUmbrella();
          break;
      case SUNNY:
          takeAHat();
          break;
      case STORMY:
          stayHome();
          break;
      default:
          doNothing();
          break;
    }
  }
}

Here, a specific action depends on the weather. This kind of code is difficult to test and maintain. This short article shows how to refactor it using a Map.

Continue reading