Questions tagged [xctwaiter]

4 questions
222
votes
14 answers

Delay/Wait in a test case of Xcode UI testing

I am trying to write a test case using the new UI Testing available in Xcode 7 beta 2. The App has a login screen where it makes a call to the server to login. There is a delay associated with this as it is an asynchronous operation. Is there a way…
Tejas HS
  • 2,565
  • 2
  • 16
  • 13
3
votes
1 answer

How to test async functions in swift using XCTWaiter and exceptions

I want to test asynchronous functions in Swift, hence as shown below, I created a XCTestExpectation and passed it on to an XCTWaiter. Now, irrespective if the expectation is fulfilled or not, I get a test ran successfully always. Can you point out…
rahulg
  • 2,183
  • 3
  • 33
  • 47
1
vote
1 answer

XCTWaiter.wait() timeout seems to take longer sometimes

To add delays in my tests I implemented this: func execute(after: TimeInterval, testBlock: () -> Void) { let result = XCTWaiter.wait(for: [expectation(description: "Delayed Test")], timeout: after) if result == XCTWaiter.Result.timedOut { …
meaning-matters
  • 21,929
  • 10
  • 82
  • 142
0
votes
1 answer

Unexpected behavior of XCTWaiter.wait

For testing purposes, I have the following test function: func test_wait() { var string: String? DispatchQueue.main.async { string = "set" print("string set") } let notNilPredicate = NSPredicate(format: "self !=…
Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116