jeudi 5 mai 2016

Measure expectation time in Xcode Unit Testing

I want to time how long it takes for a notification to be called in my app. I have a test setup like so:

func testLoadingPerformance() {
    self.measureBlock {
        self.expectationForNotification("Loaded", object: nil, handler: nil)
        self.waitForExpectationsWithTimeout(30, handler: nil)
        print("loaded")
    }
}

I've set breakpoints and the notification is definitely called during the test, and waitForExpectationsWithTimeout continues the execution as "loaded" gets printed.

However the test never finishes in Xcode and it just runs until it times out. I know that the block was definitely executed though, so why won't it pass?

Aucun commentaire:

Enregistrer un commentaire