iOS单元测试中的期望失败

时间:2020-05-12 13:31:22

标签: ios swift

我有以下测试,检查要实现的多个期望。但是由于某种原因,该测试始终会失败。我猜我的通知没有触发。

function Person(name){
     this.name = name;
}

Person.prototype.sayHi = function(){
     return "Hi " + this.name;}
```

Why the latter is better ?

AlertManager在下面实现:

class when_posting_two_alerts: XCTestCase {

    func test_generates_two_notifications() {

        let alertManager = AlertManager()

        let exp = expectation(forNotification: Notification.Name.alertNotification, object: alertManager, handler: nil)
        exp.expectedFulfillmentCount = 2

        alertManager.postAlert()
        alertManager.postAlert()

        wait(for: [exp], timeout: 1)

任何想法为什么测试会持续失败?

0 个答案:

没有答案