What framework should I use to start unit testing on iOS?

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:

  1. red or green icons next to your failing or passing tests, respectively
  2. output in the Test Navigator, again with red or green icons
  3. the ability to run a single test case
  4. the ability to run all the tests in a class
  5. a red line in the editor when a test fails, showing you exactly which assertion failed
  6. 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.

We won't send you spam. Unsubscribe at any time. Powered by ConvertKit