我正在尝试将以下测试用例从quick / nimble转换为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")
}
}
我在上面的代码中做错了吗?
答案 0 :(得分:0)
这有效:
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")
}
}