small medium large xlarge

iOS Unit Testing by Example

May 22, 2019

We know testing is important, but if you don't test the right things, your results will be useless, or worse, misleading. Knowing what to test, when, and in what circumstances is central to an automated testing program. Apple provides the XCTest framework in Xcode, but using it effectively takes practice. Jon Reid has the techniques you need, with demonstrations of how to use them.

Start testing the right way today!

iOS Unit Testing by Example: XCTest Tips and Techniques Using Swift

Manual code and UI testing get slower the deeper your navigation hierarchy goes. It can take several taps just to reach a particular screen, never mind the actual workflow tests. Automatic unit testing offers such rapid feedback that it can change the rules of development. Bring testing to iOS development, even for legacy code. Use XCTest to write unit tests in Swift for all your code.

iOS developers typically reserve unit tests for their model classes alone. But that approach skips most of the code common to iOS apps, especially with UIViewControllers. Learn how to unit test these view controllers to expand your unit testing possibilities. Since good unit tests form the bedrock for safe refactoring, you're empowered to make bold changes. Learn how to avoid the most common mistakes Swift programmers make with the XCTest framework. Use code coverage to find holes in your test suites. Learn how to identify hard dependencies.

Reshape the design of your code quickly, with less risk and less fear.

Now in beta from pragprog.com/book/jrlegios.

Upcoming Author Appearances

  • 2019-05-24 Michael Keeling, XP2019 in Montréal, Canada
  • 2019-06-06 Jeff Langr, Agile + DevOps West 2019, Las Vegas, US
  • 2019-06-25 Kevin Hoffman, KubeCon / CloudNative Con Shanghai
  • Did You Know?

    Please note our ebooks do not contain any Digital Restrictions Management and have always been DRM-free. For us, "DRM-free" means "freedom." You should own the books you've paid for and read them on whatever device is handy—your laptop, iThingy, BlueBerry, you name it. We think ideas should outlast any device you put them on.

    And you can always come back and redownload your books when needed, using your account on pragprog.com. We're here to make your life easier.

    Don't Get Left Out

    Are your friends jealous that you get these spiffy email newsletters and they don't? Clue them in that all they need to do is create an account on pragprog.com (email address and password is all it takes) and select the checkbox to receive newsletters.

    Are you following us on Twitter and/or Facebook? Here's where you can find us and keep up with the latest news and commentary, and occasional discounts:

    Tell your friends! Tweet this

    Follow us on Twitter: @pragprog, @pragpub, Andy Hunt @PragmaticAndy.

    Coming Soon:

    • Build Chatbot Interactions: Responsive, Intuitive Interfaces with Ruby, in print
    • Web Development with Clojure, Third Edition, in beta
    • Small, Sharp Software Tools: Harness the Combinatoric Power of Command-Line Tools and Utilities, in print
    • Test-Driven React: Find Problems Early, Fix them Quickly, Code with Confidence

    Recently Released:

    Thanks for your continued support,

    Andy Hunt Publisher, Pragmatic Bookshelf

    Books • eBooks • PragPub Magazine • Audiobooks and Screencasts
    PragProg.com