Learning about iOS development?
I am the author of iOS 17 Fundamentals, Building iOS User Interfaces with SwiftUI, and eight other courses on Pluralsight.
Deepen your understanding by watching!
I am the author of iOS 17 Fundamentals, Building iOS User Interfaces with SwiftUI, and eight other courses on Pluralsight.
Deepen your understanding by watching!
Swift Unit Testing Resources
As I’ve researched Test Driven Development practices in general, and for iOS / Mac applications, I’ve been helped by several sources. I’ve also discovered a few things the hard way, so I’m combining and maintaining this list of resources to help point you in some helpful directions as you adventure in unit testing your iOS apps.
Pluralsight Courses
- Play by Play: TDD with Brad Wilson – Awesome, awesome course. I learned some really great techniques from this one. The course is geared toward .Net development using Visual Studio, C#, and Moq, but you should still watch it if you’ve got a subscription – the techniques used can be done on other platforms. I’ve been practicing the techniques in Swift (minus the mocking framework).
- TDD as a Design Tool – Geared toward web development with JavaScript / AngularJS, but has some useful patterns.
Blogs
- How to write unit tests in Swift with XCTest – Josh Brown gives a nice overview of the unit testing capabilities offered in Xcode and how Swift can be used as the testing language of choice.
- Swift: Unit Testing Tips and Tricks – @NatashaTheRobot offers some practical advice in a tips and tricks style blog post.
- iOS Unit Testing – Some good introductory articles to browse. Offers a few things in Swift, but much of his content is in Objective-C.
- Write your first Unit Test in Swift – Learn how to write the most basic, but still useful, Unit Tests in Swift with XCTest.
User Group Talks
- Adam Leonard – Test-Driven Development in Swift using Quick (July 2014) – Talk given by @adamjleonard at a Brooklyn Swift Developers Meetup in July.
At andrewcbancroft.com
- Don’t Write Legacy Swift – Motivations for testing your code.
- TDD for iOS in Swift – What’s the Goal? – Before actually doing Test Driven Development (TDD) for your iOS / Mac app, it’s really important to ask a very fundamental question: What’s the goal? I discuss two goals for testing your iOS / Mac apps.
- Improvements to Unit Testing in Swift with Xcode 7 Much of the pain involved in getting set up to write unit tests in Swift has been alleviated by improvements in Xcode 7. This article analyzes these improvements to ease your unit testing workflow.
- Getting Started with Unit Testing in Swift – While getting set up to write unit tests in Swift isn’t difficult, it isn’t exactly intuitive. This 5-step guide will get your project set up to write unit tests in Swift.
- An (Almost) TDD Workflow in Swift – When I find myself staring at the screen, paralyzed because I’m “not supposed to write actual production code until the test is written”, I often turn to the workflow that describe in this post, to help me break through to being productive.
- Unit Testing Model Layer with Core Data and Swift – Exploration of testing when your project uses Core Data. This post provides a walk-through of setting up an in-memory data store to test with NSManagedObjects.
- Swift Unit Testing – Verifying Method Calls – Screencast showing how to verify method calls in Swift unit tests.
- Swift Access Control – Implications for Unit Testing – Pointer on how to make code from your main project visible in your Test project.
- Creating “Mocks” and “Stubs” in Swift – Essentially a discovery I made about how to create fake objects and override those objects’ methods. You’d do this to isolate and control the object’s behavior in order to enable or ease the testing process.