책 이미지
책 정보
· 분류 : 외국도서 > 컴퓨터 > 프로그래밍 > 애플 프로그래밍
· ISBN : 9781484270011
· 쪽수 : 288쪽
· 출판일 : 2021-07-02
목차
Chapter 1: Introduction
Introduces the reader to the concept and value of testing and test-driven development with small Swift examples and a focus on what the long term advantages of adopting TDD as a methodology to write software are.
● What is a test?
● Roll your own tests. ?Before looking at testing principles and TDD, we'll look at how to write code that calls other code and checks its results.
● Why testing.
● TDD & Red-Green-Refactor. ?In which we'll also re-write the examples above in a test-driven fashion.
● TDD vs. testing.
Chapter 2: TDD in Swift
Applies the basics of TDD discussed in the previous chapter to the real-world context of Swift, Xcode, and XCTest.
● Meet XCTest. ?A quick overview of XCTest, Apple's test framework, and its core assertions. We'll dive into the details of the framework and the assertions as the book progresses.
● Compiler errors as part of the red stage. ?Because Swift is a strongly typed and compiled language, it can show compiler errors while writing tests which are as useful as failing tests to guide the development of the code
● TDD warm-up example #1
● TDD warm-up example #2
● TDD warm-up example #3. ?Detailed examples of TDDing Swift code aimed at solidifying the red-green-refactor principles and exploring the core APIs of XCTest.
Chapter 3: How to TDD New Code
Launches into real-world test-driven development of an iOS application. We’ll look at pure logic components as they are the simplest to test and allow us to reiterate the TDD basics. Pure logic components are also at the base of the TDD methodology itself and have the advantage of being portable across architecture patterns and even application frameworks. The pure logic component it builds is the data source for a list of items, which is a common task iOS developers face.
● What if your app was a CLI? ?To TDD iOS applications effectively, we need to keep as much logic outside the scope of UIKit as possible, treating the framework as only the delivery layer for our information to the user and their interactions with our business logic.
● TDD the number of sections.
● TDD the number of rows in a section.
● TDD getting the element for a row in a section.
Chapter 4: Put UIViewController in a Test Harness
Shows how to write tests exercising UIViewController subclasses.
● Setting up the application scaffold. ?How to remove Xcode's unnecessary boilerplate.
● TDD adding a view controller to the app.
● View controller life cycle and tests.
● TDD adding a table view to the view controller.
● TDD using the data source in the view controller.
Chapter 5: Test the Contents of the UI.
Shows how to test how the view layer renders data by introducing an abstraction layer describing the view data, i.e., the humble view pattern
● The humble view pattern
● TDD generating the view data from the model data
Chapter 6: Change Existing Code Driven by Tests
Shows why the TDD process is valuable when modifying existing code?not only when writing new code. In fact, most of a software developer's job has to do with interacting with existing code.
● How tests can serve as a guide to change existing behavior.
● TDD expanding the view data defined in the previous chapter to be insatiable from a different type of model data.
● TDD expanding the data source from the previous chapters to use different types of model data.
● The fixture pattern.? How to centralize the definition of input value types for the tests.
Chapter 7: Test Delegates
Shows how to test delegates, a common pattern when working with UIKit and AppKit. This chapter introduces the concept of ?test double? and its first concrete example: the ?spy?.
● Setting up the stage. Using a delegate to decouple navigation between screens
● TDD adding a button to trigger the navigation using the spy test double for the delegate
● TDD the actual implementation of the delegate object
Chapter 8: Test Code Interfacing with the Network
Explores the challenge of testing asynchronous code interfacing with the network and how to
use Swift protocols and the ?stub? test double to do so.
● The limits of testing networking code directly
● How to abstract the network implementation from the business logic
● TDD networking code using the stub test double
Chapter 9: Test Code Storing Data
Presents the performance and runtime challenges of interacting with the storage layer in the tests, and how to mitigate them with a new test double: the ?fake.
● Examples of issues when testing code that persists values
● How to build a fake UserDefault for testing
● How to use a fake to verify the behavior of code interacting with storage
● Sidebar on the benefits of abstracting the storage implementation
Chapter 10: Test Code Interfacing with Third-Party Dependencies
Shows the use of our final test double,the?dummy,? to satisfy a dependency requirement with something that doesn't affect the behavior of the system under test.
● Third-party dependency example: analytics● How to insulate from third-party dependencies using Swift protocols
● How to avoid calling analytics in our test using the dummy test double
● How to test code interacting with the analytics using the test doubles we've learned about so far
Chapter 11: Fix Bugs Driven by Tests
Shows that the TDD workflow is suitable for bug fixing and makes the process simpler. By starting from a test that reproduces the bug, we can get insights on the possible causes, and once the test passes ?i.e., the bug has been fixed? we have a regression test to prevent the bug from happening again.
● How TDD can help with fixing bugs, and why this is valuable
● Example of a bug in the codebase we've implemented so far and how to fix it with TDD #1
● Example of a bug in the codebase we've implemented so far and how to fix it with TDD #2
● Example of a bug in the codebase we've implemented so far and how to fix it with TDD #3
Chapter 12: Testing Behavior vs. Testing Implementation
Looks back on the different strategies seen over the book and how they focus on testing behavior rather than implementation. This approach leads to tests that are useful to the developers rather than a maintenance burden.
● The difference between testing behavior and implementation
● Tests as a long term aid to development
● Example #1 ?How testing the networking code using a Spy instead of a Stub would have been harder to change
● Example #2
● Example #3
Chapter 13: Incorporate TDD in Everday Development
Provides the reader with food for thought on how to incorporate TDD in their everyday development going beyond this book.
● TDD as a software development philosophy.
● Slowing down now to go faster later.
● How maintaining a fast feedback loop can keep you productive.
Chapter 14: Conclusion
Points the reader to further areas to explore in their journey to master the TDD craft.
● The elephant in the room: test suites run time
● Running tests in Continuous Integration
● UI testing
● Snapshot testing
● Property-based testing
Appendix: Cheat-sheet.
Serves as reference section for the reader with snippet-like versions of the key concepts taught in the book.
● Xcode testing keyboard shortcuts
● Asynchronous expectation.
● Fake. Stub. Spy. Dummy.
Appendix: The Quick testing framework and Nimble assertions framework
Presents the Quick and Nimble open source libraries that can enhance testing using the final versions of the tests written throughout the book.














