我正在尝试将以下测试用例从快速/灵活转换为 xctest:
expect(foundation.appGuid).toEventually(equal(guidValue))
下面是我正在使用的代码,但测试崩溃了:
let successPredicate = NSPredicate(format: "SELF MATCHES %@", guidValue)
expectation(for: successPredicate, evaluatedWith: foundation.appGuid) {
return foundation.appGuid == guidValue
}
waitForExpectations(timeout: 5) { (error) -> Void in
if error != nil {
XCTFail("foundation.appGuid NOT Equal to guidValue")
}
}
我在上面的代码中做错了什么吗?
最佳答案
这有效:
let successPredicate = NSPredicate(format: "SELF == %@", self.guidValue)
expectation(for: successPredicate, evaluatedWith: foundation.serviceConfig.appGuid) {
return foundation.serviceConfig.appGuid == self.guidValue
}
waitForExpectations(timeout: 5) { (error) -> Void in
if error != nil {
XCTFail("foundation.serviceConfig.appGuid NOT Equal to guidValue")
}
}
关于swift - xctest 使用 NSPredicate 最终取代 Quick/Nimble,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42775496/