我有以下测试,检查要实现的多个期望。但是由于某种原因,该测试始终会失败。我猜我的通知没有触发。
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)
任何想法为什么测试会持续失败?