vendredi 30 décembre 2016

How can I test this rxJava code?

void start() {
    bar.foo()
        .filter(i -> i % 2 == 0)
        .subscribeOn(computation())
        .observeOn(io())
        .subscribe(new FooSubscriber());
}

In this function I see 3 points to test:

  1. Verify that I call bar.foo().
  2. Verify that the filter is correctly implemented.
  3. Verify that I'm subscribed to bar.foo().

The first point is easy to test with Mockito.verify(). But I have no idea about how to test the other points.

How can I test this code? Must I refactor it? How?

Please, think that filter is just an example, I have a big chain with different operators.

Aucun commentaire:

Enregistrer un commentaire