Publisher probe

In the preceding section, we used StepVerifier to assert the steps executed in a reactive chain. However, these are often simple chains that can be validated end-to-end in a single test case. There may be scenarios where we need to inject a Publisher into a service or a method and verify the published signals. In such cases, we can instrument an existing Publisher using the PublisherProbe utility. The probe keeps track of signals published by the Publisher. In the end, we can assert and verify the final state of the probe. The utility helps to unit test a service or  method executing some specific logic on a Reactive Publisher.

A PublisherProbe can be constructed using either of the following methods:

  • PublisherProbe.Of(ExisitingPublisher) ...

Get Hands-On Reactive Programming with Reactor now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.