3

I am new to unit testing in iOS and need to write unit test for an iOS 7 application. I see that XCTest is there to write unit test with the help of test navigator and assistant editor. Since "unit testing" means we are testing a piece of code [which can be a single method or a group of related methods ] . How can we write unit test for UI ? Let say we do have a settings screen at start of application which is having some set of options that user needs to select and then it will be saved to NSUserDefaults for later use. My question: How we use XCTest to: 1. Show UI [user interface is in storyboard ] so as to be able to verify the various UI elements on it including some custom drawn UI working.

May be I am a little confused over using XCTest for UI's unit testing so it would be great if anyone can clarify on above.

I have also seen apple's UIAutomation but how can we integrate it into our test target ?

Senseful
  • 86,719
  • 67
  • 308
  • 465
user2788672
  • 245
  • 4
  • 15

2 Answers2

4

If you want to test the UI of your app (as you point out), you need to implement 'system tests' or 'integration tests' not unit tests. So you need to research on UIAutomation instead of XCTests.

And there is nothing of an integration of the system tests into your test target. You need to run the instruments app of Xcode and there you can test your app. Take al look at this web, it helped me.

lihudi
  • 860
  • 1
  • 12
  • 21
1

UI testing is available in XCTest since xcode 7 - see https://developer.apple.com/videos/play/wwdc2015-406/ for more information