jeudi 16 avril 2015

Unit Test Swift- casting view controller from storyboard not working

I have written the below test case which worked fine in swift 1.1. But in 1.2 its breaking.



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")
}
}


Error while running the unit test


Could not cast value of type 'sportscalendar.MKAboutMkodoViewController' (0x105b0ad30) to 'sportscalendarTests.MKAboutMkodoViewController' (0x116e51d20).


I have done enough research to resolve this issue. But couldn't able to do it. I hope some of you come across this problem and will able to help me here.


Aucun commentaire:

Enregistrer un commentaire