Hello Greg, Nice video as usual, But i have a question. Is there is a way to test Asynchronous tasks without the delay option that you represented in this video. I don’t want to add time to the test method. I just want wait the code finish with it self, and when it’s finish, it continue running the code. Is there is a way to do that ?
I think you mean the timeout value rather than “delay”? It’s not actually a delay that makes your code run slower — it’s a timeout so that the test doesn’t wait around forever.
For example, if there’s a bug in your async task and it never completes, your test would wait forever and never complete. You can always set the timeout to 999999 or some large value, but I’d suggest a reasonable ceiling depending on what you’re testing. If you set a timeout of 10 seconds but your expectation is fulfilled in 0.5 seconds, then the test will take 0.5 seconds. Again, the 10 second value is just a maximum that ideally won’t be reached unless something has gone wrong.
OK, every thing is clear now, thank you Greg
Please suggest why we need the dispatch_sync while same thing can be achieved with the normal usage of function.