I am trying to implement UI testing with BDD using Cucumberish framework. I understand quite well the Feature files parsing system and I managed to tests some UI elements of the main screen.
However I would like to load any controller from storyboard before using UI testing on the corresponding screen.
Here is my initialization code:
@objc class CucumberishSwiftInit: NSObject {
@objc class func CucumberishSwiftInit()
{
var application : XCUIApplication!
//A closure that will be executed just before executing any of your features
beforeStart { () -> Void in
application = XCUIApplication()
}
//A Given step definition
Given("the app is running") { (args, userInfo) -> Void in
application.launch()
let bundle = Bundle.main
// I double checked the storyboard name and I can access it in my Unit Tests target
// application crashes here
let storyboard = UIStoryboard(name: "Main", bundle: bundle)
// never executed
Swift.print("storyboard \(storyboard)")
}
let bundle = Bundle(for: CucumberishSwiftInit.self)
Cucumberish.executeFeatures(inDirectory: "Features", from: bundle, includeTags: nil, excludeTags: ["skip"])
}
}
Some feature file:
@run @welcome
Feature: Some feature
Some feature desc
Scenario: Can load screen
Given the app is running
...
The application crashed on the UIStoryboard init statement, caught "NSInvalidArgumentException", "Could not find a storyboard named 'Main' in bundle NSBundle (loaded). I have no clue why as it is working using with my unit tests.