If you want to get started quickly, don’t waste your time searching for a good unit testing framework — just use the XCTest framework. It’s built in to Xcode, easy to set up, easy to use, and works well. When you’re writing your first unit tests for iOS, you don’t need the distraction of researching a new third-party library, especially when XCTest is so good. Plus, using XCTest means you don’t have to depend on a third-party framework that may someday be abandoned, unsupported, or broken.
When you use XCTest in Xcode, you get:
- red or green icons next to your failing or passing tests, respectively
- output in the Test Navigator, again with red or green icons
- the ability to run a single test case
- the ability to run all the tests in a class
- a red line in the editor when a test fails, showing you exactly which assertion failed
- a file template for quickly creating a new test class
Don’t shop around for the best unit testing framework for iOS; just go with what’s built in. Use XCTest.
Should you be writing unit tests for your app?
Unit testing for iOS can be lonely — most iOS developers don't seem to be doing it. Should you be writing unit tests? What are the benefits of unit testing, anyway? And if it is worth the effort, how do you get started? Enter your name and email in the boxes to get answers to your questions.