Testing Reactor pipelines

Unit testing Reactor pipelines is quite hard. This is because Reactor declares behaviors rather than states that can be validated. Fortunately, Reactor comes with utility classes that can assist in unit testing. The testing utilities are bundled in the reactor-test component. reactor-test provides us with the following three components:

  • StepVerifier: Allows us to validate a pipeline configuration and operators
  • TestPublisher: Allows us to produce test data to enable testing operators
  • PublisherProbe: Enables us to validate an existing publisher

Before we proceed, let's first add reactor-test to our build.gradle. We do not need to specify the version of this as that is defined by the org.springframework.boot plugin: ...

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.