在 XCTest 中我可以用来expectation(forNotification:)
测试 NSNotificationCenter 发布通知如下:
func testLoginNotification() {
let notificationExpectation = expectation(forNotification: .login, object: nil, handler: nil)
methodPostNotificationLogin()
wait(for: [notificationExpectation], timeout: 2)
}
如何在快速测试中做到这一点?
@Test fun loginNotification() {
#expect()
}