Skip to content

Instantly share code, notes, and snippets.

View KaneCheshire's full-sized avatar

Kane Cheshire KaneCheshire

View GitHub Profile
func test_settings() {
Scenario("Logging in and navigating to settings") {
Given(I: logIn)
When(I: selectTabBar(tab: .settings))
Then(I: seeSettingsScreen)
}
Scenario("Selecting support") {
Given(I: seeSettingsScreen)
When(I: selectSupportCell)
func test_settings() {
Scenario("Logging in and navigating to settings") {
Given(I: logIn)
When(I: selectTabBar(tab: .settings))
Then(I: seeSettingsScreen)
}
}
struct Scenario {
@discardableResult
init(_ name: String, _ handler: () -> Void) {
XCTContext.runActivity(named: name) { _ in
handler()
}
}
}
struct Step {
@discardableResult
init(I handler: () -> Void) {
runActivity(for: handler)
}
@discardableResult
init(I handler: @autoclosure () -> Void) {
runActivity(for: handler)
// PhotosTests.swift
class PhotosTests: XCTestCase, LoginContext, PhotosContext {
func test_editingPhotos() {
Given(I: navigateToPhotos)
When(I: selectEditButton)
Then(I: seeEditOptions)
}
private func selectEditButton() {
// PhotosContext.swift
protocol PhotosContext {}
extension PhotosContext where Self: LoginContext {
func navigateToPhotos() {
logIn()
selectPhotosButton()
seePhotosScreen()
}
// PhotosTests.swift
class PhotosTests: XCTestCase, LoginContext {
func test_editingPhotos() {
Given(I: navigateToPhotos)
When(I: selectEditButton)
Then(I: seeEditOptions)
}
private func navigateToPhotos() {
// PhotosTests.swift
class PhotosTests: XCTestCase, LoginContext {
func test_navigatingToPhotos() {
Given(I: logIn)
When(I: selectPhotosButton)
Then(I: seePhotosScreen)
}
private func selectPhotosButton() {
// LoginContext.swift
protocol LoginContext {}
extension LoginContext {
func logIn() {
// Log in code
}
}
// PhotosTests.swift
class PhotosTests: XCTestCase {
func test_navigatingToPhotos() {
Given(I: logIn)
When(I: selectPhotosButton)
Then(I: seePhotosScreen)
}
private func logIn() {