Closed jordi-chacon closed 10 years ago
You closed this issue, did you solve the problem ? :)
Yes, I did a workaround. I built a mechanism, just for testing purposes, which is basically a queue of all the asynchronous db operations that are ongoing at any time. From within the testcase, I wait for that queue to be empty before doing any assertions. That works fine and solved my problem!
Hi!
I am writing a few tests for code that does business logic and triggers asynchronous db operations through sprinkles. My tests are basically failing when they expect certain data to be present in db, but the data is missing due to the async write not being completed yet. Therefore, for testing purposes, it seems that I need a way to wait for the async jobs to be finished before I do my assertions.
I have taken a quick look at Sprinkles but there doesn't seem to be a waiting mechanism, is that correct? Does Android provide a generic way to wait for all ongoing AsyncTasks to be completed? Otherwise, any tips on how to tackle this problem?
Thanks!