Book description
Leverage Swift to practice effective and efficient test-driven development (TDD) methodology. Software testing and TDD are evergreen programming concepts—yet Swift developers haven't widely adopted them. What's needed is a clear roadmap to learn and adopt TDD in the Swift world. Over the past years, Apple has invested in XCTest and Xcode's testing infrastructure, making testing a new top priority in their ecosystem. Open-source libraries such as Quick and Nimble have also reached maturity. The tools are there. This book will show you how to wield them.
TDD has much more to offer than catching bugs. With this book, you’ll learn a philosophy for building software. TDD enables engineers to solve problems incrementally, writing only as much code as necessary. By decomposing big problems into small steps, you can move along at a fast pace, always making visible progress.
Participate in the test-driven development journey by building a real iOS application and incorporating new concepts through each chapter. The book's concepts will emerge as you figure out ways to use tests to drive the solutions to the problems of each chapter. Through the TDD of a single application, you’ll be introduced to all the staples and advanced concepts of the craft, understand the trade offs each technique offers, and review an iterative process of software development.
Test-Driven Development in Swift provides the path for a highly efficient way to make amazing apps.
What You'll Learn
- Write tests that are easy to maintain
- Look after an ever-growing test suite
- Build a testing vocabulary that can be applied outside the Swift world
- See how Swift programming enhances the TDD flow seen in dynamic languages
- Discover how compiler errors can provide the same helpful guidance as failing tests do
Who This Book Is For
Mid-level developers keen to write higher quality code and improve their workflows. Also, developers that have already been writing tests but feel they are not getting the most out of them.
Table of contents
- Cover
- Front Matter
- 1. Why Test-Driven Development?
- 2. XCTest Introduction
- 3. Getting Started with Test-Driven Development
- 4. Test-Driven Development in the Real World
- 5. Changing Tests with Fixtures
- 6. Testing Static SwiftUI Views
- 7. Testing Dynamic SwiftUI Views
- 8. Testing Code Based on Indirect Inputs
- 9. Testing JSON Decoding
- 10. Testing Network Code
- 11. Injecting Dependencies with @EnvironmentObject
- 12. Testing Side Effects
- 13. Testing a Conditional View Presentation
- 14. Fixing Bugs and Changing Existing Code with TDD
- 15. Keeping Tests Isolated with Fakes and Clear with Dummies
- 16. Conclusion
- Back Matter
Product information
- Title: Test-Driven Development in Swift: Compile Better Code with XCTest and TDD
- Author(s):
- Release date: July 2021
- Publisher(s): Apress
- ISBN: 9781484270028
You might also like
video
Practical Test-Driven Development with Xcode and Swift: Write Modularized Code for TDD with XCTest and UIKit
Write better, more robust, and well-architected code. Then put tests on CI with every run, so …
book
Test-Driven iOS Development with Swift - Fourth Edition
Build robust applications using TDD with Swift 5.5 and become a TDD expert by writing tests …
book
Hands-On Design Patterns with Swift
From learning about the most sought-after design patterns to a comprehensive coverage of architectural patterns and …
book
iOS Unit Testing by Example
Fearlessly change the design of your iOS code with solid unit tests. Use Xcode's built-in test …