Test Driven Development with Unit Tests in Xcode (XCTest) - Swift TDD Code Kata (3/4)

Опубликовано: 12 Март 2026
на канале: Paul Solt
1,343
16

Part 3/4: Learn how to write Swift code with Test Driven Development (TDD). This 4 part series is based on my guest lecture that I gave for Lambda School students in the iOS Development track.

This video series was not sponsored or endorsed by Lambda School.

Code: https://github.com/PaulSolt/TestingTi...
Lambda School iOS: https://lambdaschool.com/courses/cs/ios/

In this lesson you'll see how to refactor your unit tests to remove duplicated logic. You want to use the DRY principle in your code and your tests: Don't Repeat Yourself.

You'll learn how to write code using a TimeTraveler based on John Sundell's article on unit testing time (Link below).

By following along and writing the code, you can turn this exercise into a Code Kata, which you can practice over again to reinforce the concepts for testing time related code.

The code uses dependency injection to provide a new date generating function, so that we can time travel in your unit tests. Unit testing is a great way to verify the logic works like you expect it to work.

Video Links
Part 1:    • Xcode Unit Testing Time Introduction - Swi...  
Part 2:    • Your First Unit Test in Xcode (XCTest) - S...  
Part 3:    • Test Driven Development with Unit Tests in...  
Part 4:    • Unit Testing and Dependency Injection to T...  

Source Code
Part 1: https://github.com/PaulSolt/TestingTi...
Part 2: https://github.com/PaulSolt/TestingTi...
Part 3: https://github.com/PaulSolt/TestingTi...
Part 4: https://github.com/PaulSolt/TestingTi...

--

Learn how to make iPhone apps from scratch using Swift, Xcode, and iOS. I teach how to use Storyboard, Auto Layout, UI Design, app ideas, and app usability.

Easy Tutorials: http://blog.SuperEasyApps.com

Follow Paul:   / paulsolt  

Email: [email protected]

Click here to Subscribe: http://www.youtube.com/subscription_c...