google / promises

Promises is a modern framework that provides a synchronization construct for Swift and Objective-C.
Apache License 2.0
3.79k stars 292 forks source link

Promise based tests failing #155

Closed spry closed 3 years ago

spry commented 3 years ago

I have a codebase that uses the promises library for async operations. I have a test suite that exercises some of these async operations. I am seeing tests that involve promises fail intermittently and/or take longer than I expect to run when they run as part of the whole test suite. If I run these tests individually they pass fine. The tests that fail use XCTestExpectation as a synchronisation mechanism.

Can you suggest things I can look at that might be causing this? The tests are isolated from network activity and other inconsistent dependencies. The dependency that the failing tests share is the promises library. I apologise if my description of the problem is too vague.

Thank you for your help.

ykjchen commented 3 years ago

Hi @spry are you able to provide any generalized examples?

Based on If I run these tests individually they pass fine, it sounds like asynchronous processes triggered by some test cases are continuing on after the test cases complete, and those processes are affecting other test cases.

There are a number of strategies for avoiding this (the waiting utility described in the docs possibly being the simplest), but having an example could make it easier to understand what strategy would be most applicable.

spry commented 3 years ago

Thank you for your help. I'm not really in a position to provide examples. Most of the code in question does involve interactions with UIKit which may be kicking off async code unintentionally. I think this is likely where the problem is coming from.

Again, thank you so much for your help.