I’m currently writing some tests against streams where I’d like to assert that given some input events in a particular order, the correct output events are emitted. I’m trying to do this with
TestProbe as follows:
val (probeOne, xs) = TestSource.probe[Int].preMaterialize() val (probeTwo, ys) = TestSource.probe[Int].preMaterialize() val r = xs zipLatest ys val sinkProbe = r.runWith(TestSink.probe[(Int, Int)]) probeOne.sendNext(1) probeOne.sendNext(2) probeTwo.sendNext(3) probeOne.sendComplete() probeTwo.sendComplete() sinkProbe.requestNext() shouldEqual (2,3) sinkProbe.expectComplete()
However, the way TestProbe works, there is no oder specified in which events are delivered. In this specific case, debugging shows that the event to probeTwo is delivered first, while I’d like it to be delivered last.
Is there a way to achieve this without manually sleep()ing between sendNext invocations?