workflow-kotlin
workflow-kotlin copied to clipboard
Detect infinite render loops in unit tests
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