3

I am testing an app which samples data. Part of the test I am setting up requires a few data points to be stored. I would like to do this by having XCTest execute the acquisition method followed by a sleep() function and yet another call to the acquisition method.

Though there are methods to wait for an expectation with timeout, there doesn't seem to be a simple wait()/sleep() method that simply pauses execution for specified amount of time. Any idea how I can do this using Xcode 6 and Swift?

1 Answer 1

5

You can use NSTimer to space out your data calls instead of locking up the app with sleep

func dataCall(timer : NSTimer) {

   // get data
}
let myTimer : NSTimer = NSTimer.scheduledTimerWithTimeInterval(4, target: self, selector: Selector("dataCall:"), userInfo: nil, repeats: false)

and of course you can alter those parameters to your liking and needs.

Sign up to request clarification or add additional context in comments.

1 Comment

ah yes, of course. that will work just fine, thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.