Skip to content

Issue using TestScheduler in XCTestCase #101

Answered by mbrandonw
edhirama asked this question in General
Discussion options

You must be logged in to vote

Hi @edhirama, this is just due to the fact that async/await is still not very testable in Swift, and so we are forced to resort to tricks like this megaYield to make sure work has time to execute:

If you want to invoke the non-async version of advance you can always wrap it in a synchronous closure and invoke it:

func test() async {
  let startTime = CFAbsoluteTimeGetCurrent()
  let test = DispatchQueue.test
  _ = { test.advance() }()
  print("##### advance #####")
  print(CFAbsoluteTimeGetCurrent() - startTime)
}

Since this isn't an issue with the library I am goi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by edhirama
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #100 on January 03, 2025 19:38.