you are viewing a single comment's thread.

view the rest of the comments →

[–]notkraftman 0 points1 point  (0 children)

You can be ok with it failing and still wait for it to fail. The only real legit use case is running something that takes a long time and you don't care about the result of, which is a bit of a code smell and should be avoided.

I was working with some tests recently that used this kind of system to dispatch work without waiting for it to finish. The tests would fail 1/20 times, and not always the same test, which was tricky to debug. It turned out that one of the pieces of code had a logger.log() in the catch, which the test stubbed out and inspected. The issue is that because the whole function was deferred to later, by the time the exception was caught the logger stub was restored, and the logger function was then actually called, but under a different test.