Reputation: 9063
I'm trying to get KIF and Quick/Nimble for iOS playing together nicely, so I can use QuickSpecs for my KIF tests.
My test currently looks like this:
class HomeSceenSpec: QuickSpec {
override func spec() {
describe("Home screen") {
it("should have a failing test") {
let tester = self.tester()
tester.waitForViewWithAccessibilityLabel("Blah")
}
}
}
}
The text 'Blah' doesn't exist and the test should fail. failWithException:stopTest:
is being called but it isn't raising an exception or causing the QuickSpec test to fail.
How do I integrate these two technologies?
Upvotes: 3
Views: 1119
Reputation: 225
We just released KIF-Quick
cocoapod that should help, see:
http://cocoapods.org/pods/KIF-Quick
Here an example of spec:
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("[email protected]")
viewTester().usingLabel("Login Password").enterText("thisismypassword")
viewTester().usingLabel("Log In").tap()
viewTester().usingLabel("Welcome").waitForView()
}
afterEach() {
tester().returnToLoggedOutHomeScreen()
}
}
}
}
}
Upvotes: 2
Reputation: 9063
It looks like there may be an issue with failWithException:stopTest:
calling recordFailureWithDescription:inFile:atLine:expected:
. (There's a good deal of swizzling going on with that method).
The solution I came to was to create a category/extension on 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)
}
}
}
Upvotes: 5