Post

Replies

Boosts

Views

Activity

Is it possible to use XCTNSNotificationExpectation in UI tests?
I'm writing a UI test for my app and am trying to determine if/when a given NSNotification is posted to the default NotificationCenter. I defined a XCTNSNotificationExpectation in my UI test:let expectation = XCTNSNotificationExpectation(name: notificationName, object: nil, notificationCenter: NotificationCenter.default) let result = XCTWaiter().wait(for: [expectation], timeout: 10)I'm posting this notification in my app, but the UI test expectation is not being fulfilled (the result is .timedOut)My guess is that the NotificationCenter that my app is posting to is not the same NotificationCenter that my UI test is listening to, because the UI test doesn't have visibility into the app's innards. Q: Are XCTNSNotificationExpectations supposed to work in UI tests? If so, can someone provide an example of what the test code should look like?Thanks in advance!
3
0
1.6k
Jan ’20
Getting error measuring signpost metrics in XCUITests
I'm running some XCUITests that utilize the measure(metrics:block:) call to gather signpost metrics (using XCTOSSignpostMetric) from the app being tested.Running the tests one at a time works just fine, but when I try to run multiple tests consecutively, all tests after the first fail with the error: "Cannot activate instrument while another is already active"Is there something that I should be doing after the measure block is run or in a tearDown() to clean up the metrics being measured? I couldn't find any documentation about cleaning up metrics, but it appears that the underlying instruments are not being cleaned up appropriately when a test case completes.Thanks in advance for any help you can offer.
5
0
1.5k
Mar ’20