iOS Unit Testing by Example

XCTest Tips and Techniques Using Swift

by: Jon Reid

Published 2020-06-22
Internal code jrlegios
Print status In Print
Pages 358
User level Intermediate
Keywords iOS, iOS apps, iOS programming, Unit testing, Swift, XCTest, testing view controllers
Related titles

Test iOS Apps with UI Automation, 978-1-93778-552-9
Swift Style, Second Edition, 978-1-68050-627-3

ISBN 9781680506815
Other ISBN Channel epub: 9781680507973
Channel PDF: 9781680507980
Kindle: 9781680507959
Safari: 9781680507966
Kindle: 9781680507959
BISACs COM051330 COMPUTERS / Software Development & Engineering / Quality Assurance & Testing
COM051010 COMPUTERS / Programming Languages / General
COM051010 COMPUTERS / Programming Languages / General

Highlight

Fearlessly change the design of your iOS code with solid unit tests. Use Xcode’s built-in test framework XCTest and Swift to get rapid feedback on all your code — including legacy code. Learn the tricks and techniques of testing all iOS code, especially view controllers (UIViewControllers), which are critical to iOS apps. Learn to isolate and replace dependencies in legacy code written without tests. Practice safe refactoring that makes these tests possible, and watch all your changes get verified quickly and automatically. Make even the boldest code changes with complete confidence.

Description

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.

Contents and Extracts