0

I have a new proyect and I want to implement UITests, but I have the following problem when I initialize the controller...

Error

My viewController identifier is MainView, my storyboard target membership marked... This sounds simple but I don´t find any solution...

Call

Thank you very much

Patrick22
  • 1
  • 2
  • In the line of code where you try to load the storyboard, you have the bundle set to nil. What happens if you use NSBundle.mainBundle() instead – robowen5mac Feb 22 '16 at 15:54
  • Same error. I tried many things :( – Patrick22 Feb 22 '16 at 15:57
  • I definitely don't have a lot of experience with UI tests, but why do you need to load a specific storyboard. From what I understand, the main storyboard will load when the application starts before you run any tests. Here is a good starter guide to UI testing...https://www.bignerdranch.com/blog/ui-testing-in-xcode-7-part-1-ui-testing-gotchas/ – robowen5mac Feb 22 '16 at 16:08
  • I followed this tutorial: http://www.raywenderlich.com/101306/unit-testing-tutorial-mocking-objects I need the viewcontroller instance for call his methods like: viewController.sendPersonToAPI(PersonInfo(firstName: "firstname", lastName: "lastname", birthday: NSDate())) – Patrick22 Feb 22 '16 at 16:15
  • OK...I think the problem is that this tutorial is meant for standard iOS unit tests, not for iOS UI tests. I am guessing that the two types of tests are set up very differently and items that work in one will not work in another...To follow this tutorial (watch out for the fact that it looks to use slightly older Swift syntax), look for the folder in your app called ApplicationNameTests, not ApplicationNameUITests and write your tests there. – robowen5mac Feb 22 '16 at 16:22
  • Thank you very much @spottedrabbit. Yo´re right. The tutorial is for Unit Tests.... Now, it´s works – Patrick22 Feb 22 '16 at 16:31
  • Great...I put something as an answer and if you don't mind accepting it...I would appreciate it. – robowen5mac Feb 22 '16 at 16:33

1 Answers1

0

OK...I think the problem is that the tutorial you mention (http://www.raywenderlich.com/101306/unit-testing-tutorial-mocking-objects) is meant for standard iOS unit tests, not for iOS UI tests. I am guessing that the two types of tests are set up very differently and items that work in one will not work in another...To follow this tutorial (watch out for the fact that it looks to use slightly older Swift syntax), look for the folder in your app called ApplicationNameTests, not ApplicationNameUITests and write your tests there.

robowen5mac
  • 866
  • 8
  • 17