-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Using expectations instead of handlers, especially the global one, could cause infinite loops when they fail.
expect.onGlobalFail = object : GlobalExpectationHandler() {
override fun handleFail(exception: ExpectationException) {
expect.fail("this will trigger an infinite loop as soon as an expectation fails")
}
}This is easy to avoid when the global handler logic is simple, which I expect to be the majority of cases, but it could be done inadvertently for more complex handlers who make various function calls, for example to disable parts of the application.
Since the purpose of the library is in part to be able to recover critical failures, it would be unfortunate to cause one. Ideally we would detect loops that are likely infinite and end them before a stack overflow. The approach could perhaps consist of detecting if multiple calls to handleFail are occurring without any of the calls returning. By inspecting the ExpectationException one could make an educated guess as to whether the same expectation is failing in a loop.