• Quarkus is a full-stack, Kubernetes-native Java framework that supports many coding styles, including reactive programming.
  • Writing clean unit/component/integration tests for Quarkus applications when a reactive approach is used is vitally important. Here we demonstrate testing reactive code, reactive messaging, and full integration testing.
  • Writing tests for validating reactive code can sound complicated, and the strategy often followed might be to either mock the classes or spin up a Kafka cluster. However, there are other alternatives.
  • It’s important to write integration tests to validate that everything works under circumstances similar to production. When managing the tradeoff between realism and testing execution time, you can use Testcontainers to initialize ephemeral instances of databases and distributed logs/queues.
  • Unit tests are a central pillar to maintain the quality of applications, but component and integration tests are also important. Quarkus excels in supporting these kinds of tests.

Quarkus is a full-stack, Kubernetes-native Java framework made for Java virtual machines (JVMs) and native compilation, optimizing Java specifically for containers and enabling it to become an effective platform for serverless, cloud, and Kubernetes environments.

Instead of reinventing the wheel, Quarkus uses well-known enterprise-grade frameworks backed by standards/specifications and makes them compilable to a binary using Graal VM.

In this article, we’ll learn how to write clean unit/component/integration tests for Quarkus applications when reactive messaging is used. We’ll see how we can write simple and clean tests for the following scenarios:

  • Reactive code
  • Reactive messaging
  • Full integration test

#java #testing #quarkus #development #microservice

Testing Quarkus Web Applications: Reactive Messaging, Kafka, and Testcontainers
3.10 GEEK