Skip to content

Can Turbine help me test a Flow without caring about the order of events? #197

Answered by JakeWharton
DougMcTuro asked this question in Q&A
Discussion options

You must be logged in to vote

There is nothing built in, but you could definitely write an extension which did this. Simply loop on awaitItem() until your condition is met and then break.

For such a function to be included in Turbine itself there's all kinds of considerations to be made. For example:

  • Does the timeout apply to the whole operation or each individual await?
  • How many items do we consume before we fail?
  • What happens to the unconsumed items?
  • How do you test for multiple conditional matches in a group of items without relying on order?

I think including such a function starts to move Turbine from being a fairly simple collector of events from a Flow and into an actual library providing assertions over a st…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DougMcTuro
Comment options

Answer selected by DougMcTuro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants