【发布时间】:2018-12-25 23:13:16
【问题描述】:
我正在尝试使用 Cucumberish 框架通过 BDD 实现 UI 测试。 我非常了解功能文件解析系统,并且我设法测试了主屏幕的一些 UI 元素。
但是,我想在相应屏幕上使用 UI 测试之前从情节提要加载任何控制器。
这是我的初始化代码:
@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"])
}
}
一些功能文件:
@run @welcome
Feature: Some feature
Some feature desc
Scenario: Can load screen
Given the app is running
...
应用程序在 UIStoryboard init 语句中崩溃,捕获“NSInvalidArgumentException”,“在捆绑包 NSBundle(已加载)中找不到名为 'Main' 的故事板。我不知道为什么它正在与我的单元测试一起使用。
【问题讨论】:
标签: swift user-interface testing cucumber bdd