Chr*_*let 3 integration-testing unit-testing ios kif
我正在尝试让KIF和Quick/Nimble for iOS很好地一起玩,所以我可以使用QuickSpecs进行KIF测试.
我的测试目前看起来像这样:
class HomeSceenSpec: QuickSpec {
override func spec() {
describe("Home screen") {
it("should have a failing test") {
let tester = self.tester()
tester.waitForViewWithAccessibilityLabel("Blah")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
文本'Blah'不存在,测试应该失败.failWithException:stopTest:正在被调用,但它没有引发异常或导致QuickSpec测试失败.
我如何整合这两种技术?
看起来failWithException:stopTest:调用可能存在问题recordFailureWithDescription:inFile:atLine:expected:.(这种方法正在进行大量的调整).
我遇到的解决方案是在QuickSpec上创建一个类别/扩展:
import Quick
import Nimble
import KIF
extension QuickSpec {
func tester(_ file : String = __FILE__, _ line : Int = __LINE__) -> KIFUITestActor {
return KIFUITestActor(inFile: file, atLine: line, delegate: self)
}
func system(_ file : String = __FILE__, _ line : Int = __LINE__) -> KIFSystemTestActor {
return KIFSystemTestActor(inFile: file, atLine: line, delegate: self)
}
override public func failWithException(exception: NSException!, stopTest stop: Bool) {
if let userInfo = exception.userInfo {
fail(exception.description,
file: userInfo["SenTestFilenameKey"] as String,
line: userInfo["SenTestLineNumberKey"] as UInt)
} else {
fail(exception.description)
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
922 次 |
| 最近记录: |