• Home
  • Public Speaking
  • Travel

Testing Asynchronous Microservices


Especially when testing asynchronous microservices, we can never be sure about the exact response time.
It depends on the communication between consecutive units. Therefore, instead of waiting for the maximum acceptable duration,
we can poll for the expected response with a polling frequency. Lets start with a sample scenario.


As it can be seen in the example, the response is polled every 1 second. If we would not get it until 10th second, the case would fail.
We use awaitility library for polling mechanism. Now let's deep dive into working principles:

Polling until a condition is met

We can check until a condition is met.(For instance until a number is greater than 3; or a string contains another substring.)


A shortcut

If we simply want to check a condition to be met (a boolean value), we can use until method without a matcher:


Here, we see AtomicBoolean type instead of Boolean; which gives us opportunity to operate Thread Safe processes.
Another point, we can notice, is callable returning methods. We can also notice how an object returning method can be used with ()->


Callable

Let's examine how it works: