【发布时间】:2015-04-16 08:32:25
【问题描述】:
我编写了以下测试用例,它在 swift 1.1 中运行良好。但在 1.2 中它的破坏。
class AboutViewController_Tests: XCTestCase
{
//var storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: NSBundle(forClass: self.dynamicType)) // Used in swift 1.1
var storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle:NSBundle.mainBundle()) // Replaced this in swift 1.2
var aboutViewController:AboutViewController!
override func setUp()
{
super.setUp()
aboutViewController = storyboard.instantiateViewControllerWithIdentifier("AboutViewController") as! AboutViewController
aboutViewController.viewDidLoad()
XCTAssertNotNil(aboutViewController, "About not nil")
}
}
运行单元测试时出错
无法将“testProject.AboutViewController”(0x105b0ad30)类型的值转换为“testProjectTests.AboutViewController”(0x116e51d20)。
我已经做了足够的研究来解决这个问题。但是做不到。我希望你们中的一些人遇到这个问题并能够在这里帮助我。
【问题讨论】:
标签: ios iphone unit-testing swift