首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >KIF和快速/敏捷

KIF和快速/敏捷
EN

Stack Overflow用户
提问于 2015-01-29 08:08:13
回答 2查看 1.1K关注 0票数 3

我试图让库夫快速/敏捷在iOS上很好地一起玩,这样我就可以在KIF测试中使用QuickSpecs。

我的测试目前如下所示:

代码语言:javascript
复制
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测试失败。

如何整合这两种技术?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-01-29 21:30:50

看起来,failWithException:stopTest:调用recordFailureWithDescription:inFile:atLine:expected:可能有问题。(这种方法有很大的变化)。

我找到的解决方案是在QuickSpec上创建一个类别/扩展:

代码语言:javascript
复制
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)
        }
    }
}
票数 5
EN

Stack Overflow用户

发布于 2016-12-26 06:01:09

我们刚刚发布了KIF-Quick cocoapod,应该会有所帮助,请参见:

http://cocoapods.org/pods/KIF-Quick

这里有一个规范的例子:

代码语言:javascript
复制
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()
                }
            }
        }
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28209769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档