These instructions were created from trial and error for the UITests Target
- Create a new Xcode project
- Include UI Tests
- In your Podfile include Cucumberish in your UITests Target
use_frameworks!
platform:ios, '11.0'
target 'AppName' do
use_frameworks!
end
target 'AppNameUITests' do
inherit! :search_paths
pod 'Cucumberish'
end
-
Run
pod install
-
In the navigation pane of your Xcode project: inside AppNameUITests folder create a new objc header file and rename it to: AppName-Bridging-Header.h and add the following line in the meantime:
#import <Cucumberish/Cucumberish.h>
-
In the navigation pane of your Xcode project: inside AppNameUITests folder create a new objc implementation file and rename it to: CucumberishTest.m and add the following contents:
#import "AppNameUITests-Swift.h"
void CucumberishInit(void);
__attribute__((constructor))
void CucumberishInit()
{
[CucumberishInitializer CucumberishSwiftInit];
}
- In the navigation pane of your Xcode project: add a new folder inside AppNameUITests folder and name it Features
Here you will create new empty files with the name of the feature follow by the .feature
file extension as an example name it Login.feature
- Add a new swift file inside the folder AppNameUITests and name it CucumberishInitializer.swift
- Inside CucumberishInitializer.swift add the following content:
import Foundation
import Cucumberish
@objc public class CucumberishInitializer: NSObject {
@objc public class func CucumberishSwiftInit() {
var application: XCUIApplication!
beforeStart { () -> Void in
application = XCUIApplication()
LoginSteps().LoginStepsImplementation()
SignUpSteps().SignUpStepsImplementation()
CommonStepDefinitions().CommonStepDefinitionsImplementation()
}
let bundle = Bundle(for: CucumberishInitializer.self)
Cucumberish.executeFeatures(inDirectory: "Features", from: bundle, includeTags: nil, excludeTags: nil)
}
}
- Create a new folder inside AppNameUITests directory and name it StepDefinitions
- As an example create a new swift file a name it LoginStep.swift , which is where the actually Gherkin language is match with Regex
import Foundation
import Cucumberish
class LoginSteps: LoginScreen {
func LoginStepsImplementation() {
Given("I'm a new user that is registering for the first time") { args, dataTable in
// call your unit test implementations
XCTAssertTrue(...)
}
When("the user submits the registration form with the following details") { args, dataTable in
// call your unit test implementations
XCTAssertTrue(...)
}
Then("the user is successfully registered") { args, dataTable in
// call your unit test implementations
XCTAssertTrue(...)
}
- Run your UITests [CMD + U] and you will see the XCTest classes being generate it in the process.