I’ve gotten sync tests running on Fire. How can I write an Async Test? I’m using Silver with Fire
Okay I’ve gotten it run. I’m leaving the solution here just as a reference for anyone looking for it in the future
public class PerformNetworkRequestWithUri : Test {
public func shouldReturnResponseForGoogleUri() {
var threadLock = ResultLock<Boolean>() //you need to create a thread lock
SKNetwork.performNetworkRequestWithUri("http://www.google.com") { //this is an async method I'm testing
response in
Assert.IsNotNil(response)
threadLock.Signal(true) //call this method to allow the thread to continue
}
threadLock.WaitFor() //ask the thread to wait till the true signal is received
}
}
1 Like