gpt4 book ai didi

swift - xctest 使用 NSPredicate 最终取代 Quick/Nimble

转载 作者:行者123 更新时间:2023-11-30 12:36:41 24 4
gpt4 key购买 nike

我正在尝试将以下测试用例从快速/灵活转换为 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com