0

End-to-End Microservice Tests with Cucumber and Spring Boot

E2E Tests with Cucumber

If you work with Microservices, you surely faced the situation in which some of your system processes only make sense after the information flows through several microservices. For instance, if you’re implementing an Event-Driven architecture, you certainly want to verify your Business Processes when events are propagated and other parts react upon them. There are several frameworks you can use for that but, for its simplicity and perfect matching with Business requirements, Cucumber is a great option. Let’s get into the process of writing end-to-end scenarios using Cucumber.

Continue Reading

0

The Complete Guide to REST (Controller) Tests in Spring Boot: Unit and Integration Tests

Spring Boot Test

There are different ways to test your Controller (Web or API Layer) classes in Spring Boot, some provide support to write pure Unit Tests and some others are more intended to be used for Integration Tests. Within this post, I’ll cover the main three test approaches available for Spring: using MockMVC in standalone mode, MockMVC together with SpringRunner, and using SpringBootTest.

Continue Reading

0

A practical book about Microservices

Microservices - The Practical Way

Microservices are getting very popular these days. This type of software architecture has a lot of advantages like flexibility and ease at scale. Mapping them into small teams in an organization also gives a lot of efficiency in development.

However, going on the adventure of microservices knowing only the benefits is a wrong call: you need to know what you are facing and be prepared for that in advance. You can get a lot of knowledge from many books and articles on the Internet but, when you get hands-on-code, the story changes.

Continue Reading

0

How to fix Eureka taking too long to deregister instances

If you use Ribbon and Eureka in your Spring Boot application, you’ll notice that the default configuration is not optimal. Eureka takes too long time to notice that a service went down unexpectedly and in the meantime, your load balancer, Ribbon, will try to connect to the dead one. On the other hand, the official Eureka documentation discourages changing the leaseRenewalIntervalInSeconds parameter so, what can we do here? This post answers that question.

Continue Reading

8

Sending and receiving JSON messages with Spring Boot AMQP and RabbitMQ

Setting up a Spring Boot application using AMQP with RabbitMQ is not really difficult, and there are many guides on the Internet showing you the basic setup. But creating an application making use of   @RabbitListener  annotations and producing and consuming messages in JSON format is trickier, so I would like to share with you a really simple but more serious approach that those hello-messaging apps.

This article covers:

  • How to send/publish Java Objects as JSON messages using Spring Boot and RabbitMQ   RabbitTemplate.
  • How to read/consume JSON messages to Java Objects using Spring Boot and RabbitMQ   @RabbitListener annotation.
  • How to send and receive Java Objects through RabbitMQ using default Java serializer.

Continue Reading

9

Test Coverage analysis (with JaCoCo and Sonar) for your Spring Boot app

One of the main metrics for a software project is Test Coverage: if done properly, it gives you a quick picture about how much code is ‘protected’ by tests.

In this article, I’ll show you how to use a minimal configuration for including JaCoCo in our Spring Boot application, and how to process this information with Sonar.

Continue Reading

0

Integration testing with Mockito and Spring Boot

Within this post, I show you how to setup properly a Unit Test in Spring Boot performing HTTP requests with Mockito. In this case, I’m testing directly against data to be placed into the model, but a similar test could be written for checking a REST API.

Sometimes testing web access with Spring Boot can be tricky. There are some specific annotations to be used, being the configuration to use maybe the most important one.

Continue Reading

11

A gamification experiment with SonarQube

Some time ago I finished a gamification MOOC by Coursera and then I decided to put it into practice in my current job since I found it really interesting. I set up a game in which the more Sonar issues you resolve, the more points you get, and you can rank in a leaderboard and obtain badges.

In this post, I’d like to share with you the results of this experiment, how people were the key to success by resolving many potential bugs and reducing our technical debt.

Update: code is now on github.

Continue Reading