workflow-kotlin icon indicating copy to clipboard operation
workflow-kotlin copied to clipboard

Detect infinite render loops in unit tests

Open zach-klippenstein opened this issue 5 years ago • 0 comments
trafficstars

If you have a worker that is incorrectly implemented, in that it always returns false from doesSameWorkAs and its Flow completes immediately, your workflow will enter an infinite render loop.

This might seem like a weird thing to do, but if your worker is a Mockito mock and you forget to override doesSameWorkAs, it's exactly what will happen. We can detect this situation in the WorkflowTester API by counting render passes, and if you hit some extraordinarily high number of passes before even running the test block, fail the test with some message about this case.

cc @afollestad

zach-klippenstein avatar Dec 20 '19 02:12 zach-klippenstein