Skip to content

XCTest Integration

Tyler-Keith-Thompson edited this page Mar 17, 2019 · 6 revisions

There have been a couple of instances where people have requested that CucumberSwift give a lot of the same control that you get with an XCTestCase so here we go:

Expectations

CucumberSwift defines a way to create expectations just like XCTestCase

Given("some precondition") { _, _ in
    let expectation = self.expectation(description: "waiting")
    self.wait(for: [expectation], timeout: 3)
}

ContinueAfterFailure

This can be a hot button topic, should a test stop executing as soon as it hits a failure, or should it keep going.

There are 2 ways of defining this:

Globally:
extension Cucumber: StepImplementation {
    public var continueTestingAfterFailure = true
}
Overridden by a step:
Given("some precondition") { _, step in //this ignores the global definition, but only for this step
    step.continueTestingAfterFailure = false
}