New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add expectNoEvents to MoleculeTurbine #77
Conversation
try { | ||
expectNoEvents() | ||
fail() | ||
} catch (t: AssertionError) { | ||
assertEquals(t.message, "Expected no events but found Item(kotlin.Unit)") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use assertFailsWith
rather than try/fail/catch. Right now you're getting lucky in that the AssertionError
that would be thrown by fail()
is being caught but is failing in the message check. Would rather using something a bit safer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
This exists in Turbine so I'm okay duplicating it here. I'll just comment once again for the record that this assertion is prone to race conditions and does not guarantee that no events will ever be produced in the future (anywhere from 1ms to the heat death of the universe). It has it's place, but no doubt someone will get upset when it's doesn't do exactly what they think. |
Would it be worthwhile to mention this in the kdoc? |
I don't think this is ever a valid assertion to make given the current implementation of the testing library. Since recomposition is delayed until you call We've moved off of this testing library internally and are experimenting with a more aggressive recomposition strategy. Once that implementation settles I think we can push it upstream here. |
Ah, yes. I thought we had a reason for not including it I just couldn't... remember. |
Please close if this is silly or useless, but I don't see another way of verifying this behavior other than expecting a timeout, which extends the runtime of a test by a full second.