我试图让库夫和快速/敏捷在iOS上很好地一起玩,这样我就可以在KIF测试中使用QuickSpecs。
我的测试目前如下所示:
class HomeSceenSpec: QuickSpec {
override func spec() {
describe("Home screen") {
it("should have a failing test") {
let tester = self.tester()
tester.waitForViewWithAccessibilityLabel("Blah")
}
}
}
}文本'Blah‘不存在,测试应该失败。正在调用failWithException:stopTest:,但它不会引发异常或导致QuickSpec测试失败。
如何整合这两种技术?
发布于 2015-01-29 21:30:50
看起来,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)
}
}
}发布于 2016-12-26 06:01:09
我们刚刚发布了KIF-Quick cocoapod,应该会有所帮助,请参见:
http://cocoapods.org/pods/KIF-Quick
这里有一个规范的例子:
import Quick
import KIF_Quick
class LoginSpec: KIFSpec {
override func spec() {
describe("successful login") {
context("home view") {
beforeEach() {
tester().navigateToLoginPage()
}
it("should open Welcome page") {
viewTester().usingLabel("Login User Name").enterText("user@example.com")
viewTester().usingLabel("Login Password").enterText("thisismypassword")
viewTester().usingLabel("Log In").tap()
viewTester().usingLabel("Welcome").waitForView()
}
afterEach() {
tester().returnToLoggedOutHomeScreen()
}
}
}
}
}https://stackoverflow.com/questions/28209769
复制相似问题