Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get access to the current UIViewController within UITest in Xcode?

Is it possible at all? I would like to test some properties on this controller after user perform some actions on UIView.

like image 216
Bartłomiej Semańczyk Avatar asked Aug 24 '15 11:08

Bartłomiej Semańczyk


1 Answers

You shouldn't be using UI Tests to test properties within your view controller. That is the Unit Test's job.

Within your unit tests you can always mock your controls or perform actions manually.

button.sendActionsForControlEvents(UIControlEvents.TouchUpInside) 

Then you can do your asserts to make sure the property changed to the correct value.

UI Tests are mainly for checking if the "button is pushing the right controller", "turning the switch to off disabled another button" etc.

Good link here for UI Test

Good link for Unit Test

like image 143
Daniel Tavares Avatar answered Nov 15 '22 22:11

Daniel Tavares