Muutke küpsiste eelistusi

E-raamat: Test-Driven Development in Swift: Compile Better Code with XCTest and TDD

  • Formaat: PDF+DRM
  • Ilmumisaeg: 01-Jul-2021
  • Kirjastus: APress
  • Keel: eng
  • ISBN-13: 9781484270028
Teised raamatud teemal:
  • Formaat - PDF+DRM
  • Hind: 61,74 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
  • Formaat: PDF+DRM
  • Ilmumisaeg: 01-Jul-2021
  • Kirjastus: APress
  • Keel: eng
  • ISBN-13: 9781484270028
Teised raamatud teemal:

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

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. 

About the Author xiii
About the Technical Reviewer xv
Acknowledgments xvii
A Gift for You xix
Chapter 1 Why Test-Driven Development?
1(12)
What Is a Test?
1(1)
Manual Testing Is Inefficient
2(1)
Code That Checks Other Code
3(4)
From Writing Tests to Writing Tests First
7(3)
From Writing Tests First to Test-Driven Development
10(1)
Key Takeaways
11(1)
Endnote
12(1)
Chapter 2 XCTest Introduction
13(14)
The Xcode Unit Test Target
13(3)
XCTestCase and Equality Assertion
16(2)
Other Assertions
18(1)
Unwrapping Optionals
18(2)
Expectations for Asynchronous Code
20(2)
XCTestCase Life Cycle
22(3)
Key Takeaways
25(2)
Chapter 3 Getting Started with Test-Driven Development
27(16)
Test List
28(1)
Fake It...Till You Make It
29(3)
Arrange, Act, Assert
32(2)
First Make the Test Pass; then Make the Code Clean
34(4)
The Compiler Is Part of the TDD Process
38(1)
Wishful Coding
39(2)
Key Takeaways
41(2)
Chapter 4 Test-Driven Development in the Real World
43(26)
The Menu Ordering App
43(1)
Whereto Begin?
44(1)
Partition Problem and Solve Sequentially
45(2)
Building the Menu
47(16)
Use the Strictest Assertions Possible
52(3)
Use the Clearest Assertion Possible
55(1)
Don't Let the Tests Crash
56(4)
Test Naming Conventions
60(2)
Red, Green, and Don't Forget Refactor
62(1)
Wiring Up the UI
63(4)
Pure Functions
67(1)
Key Takeaways
68(1)
Chapter 5 Changing Tests with Fixtures
69(10)
The Hidden Cost of Source Changes
70(1)
Fixtures
71(2)
Fixtures vs. Convenience Initializers
73(1)
Fixtures Make the Test Actors Explicit
74(2)
Fixtures Are Composable
76(1)
Introduce Fixtures As Early As Possible
76(1)
Practice Time
77(1)
Key Takeaways
77(1)
Endnote
78(1)
Chapter 6 Testing Static SwiftUI Views
79(18)
The Problem with Presentation Logic in the View
79(2)
Decouple Presentation Logic from the View Implementation
81(1)
Preparatory Refactor: Reduce the Working Surface Area
82(1)
ViewModel
83(3)
Using the ViewModel in the View
86(1)
Beyond Testability
87(1)
ViewModels Everywhere!
88(6)
Key Takeaways
94(1)
Endnotes
94(3)
Chapter 7 Testing Dynamic SwiftUI Views
97(22)
How SwiftUI and Combine Make Seamless View Updates Possible
98(1)
Make the ViewModel Stream Updates with ObservableObject
99(6)
The Dependency Inversion Principle
105(6)
Decouple the ViewModel from the Data Fetching with DIP
108(3)
How to Test Async Updates of @Published Properties
111(4)
Mystery Guest
115(1)
Practice Time
116(1)
Key Takeaways
117(2)
Chapter 8 Testing Code Based on Indirect Inputs
119(14)
The Stub Test Double
120(11)
Make Error Handling Explicit with Result
124(7)
Practice Time
131(1)
Key Takeaways
132(1)
Chapter 9 Testing JSON Decoding
133(18)
Option 1 Inline Strings
137(1)
Option 2 JSON Files
138(4)
Which Option to Choose?
142(2)
Is Testing JSON Decoding Worth It?
144(4)
Practice Time
148(1)
Key Takeaways
149(1)
Endnote
150(1)
Chapter 10 Testing Network Code
151(16)
Why You Shouldn't Make Network Requests in Your Unit Tests
152(5)
How to Decouple the Unit Tests from the Network
157(3)
Simulate Network Requests Using a Stub
160(4)
A Third-Party Alternative
163(1)
Practice Time
164(1)
Key Takeaways
165(1)
Endnote
166(1)
Chapter 11 Injecting Dependencies with @EnvironmentObject
167(18)
How Dependency Injection Keeps Each Test Isolated
170(14)
Dependency Injection vs. Directly Accessing Shared Instances
176(1)
Dependency Injection with @EnvironmentObject
177(4)
The Downside of @EnvironmentObject
181(1)
@EnvironmentObject vs. Directly Accessing Shared Instances
182(2)
Practice Time
184(1)
Key Takeaways
184(1)
Chapter 12 Testing Side Effects
185(12)
Third-Party Dependencies Are the Same As All Dependencies
188(1)
The Benefit of Abstracting Third-Party Dependencies
189(1)
Build Wrappers for Third-Party Dependencies
189(2)
The Spy Test Double
191(3)
The Downside of Using Spies
194(1)
Practice Time
195(1)
Key Takeaways
195(2)
Chapter 13 Testing a Conditional View Presentation
197(22)
Informing the User of the Checkout Completion
198(5)
How to Test Asynchronous Code When There Is No Callback
203(5)
Wiring Up the View
208(2)
Testing the Alert Dismiss Behavior
210(6)
Key Takeaways
216(3)
Chapter 14 Fixing Bugs and Changing Existing Code with TDD
219(6)
Fixing Bugs Driven by Tests
219(3)
Changing Existing Code Driven by Tests
222(2)
Key Takeaways
224(1)
Chapter 15 Keeping Tests Isolated with Fakes and Clear with Dummies
225(10)
Fake: How to Bypass Slow or Stateful Dependencies
226(4)
Dummy: How to Provide Dependencies That Are Required but Irrelevant for the Behavior Being Tested
230(3)
Key Takeaways
233(2)
Chapter 16 Conclusion
235(8)
More Than Just Testing
236(1)
TDD and Software Design
237(1)
TDD and Productivity
238(1)
TDD and Product Development
239(2)
Endnote
241(2)
Cheatsheet
243(8)
XCTest Test Structure
243(1)
How to Test Asynchronous Code
244(1)
How to Test Asynchronous Code When There Is No Callback
244(1)
How to Test Combine Publishers
245(2)
How to Test Changes to SwiftUI Published Properties
247(1)
Fixture Extension
248(1)
Stub Test Double
248(1)
Spy Test Double
249(1)
Fake Test Double
249(1)
Dummy Test Double
250(1)
Appendix A Where to Go from Here
251(8)
Continuous Integration
251(1)
Snapshot Testing
252(1)
UI Testing
253(1)
API Integration Testing
254(1)
Use Modularization to Tame Long Build Times
255(1)
How to Convince Your Team to Adopt TDD
256(3)
Appendix B Testing with Quick and Nimble
259(8)
Nimble
260(2)
Quick
262(5)
Appendix C TDD with UIKit
267(16)
How to Unit Test a UIViewController
268(5)
How to Test Table Views
273(3)
How to Test ViewController Navigation and Presentation
276(5)
What About AppKit and WatchKit?
281(2)
Index 283
Gio Lodi spent the past decade writing tests. He began with full-stack web development before moving into iOS programming and, more recently, into mobile infrastructure engineering. Ruby on Rails introduced him to the TDD world, and he fell in love with the fast-paced feedback loop. Any big problem could be decomposed in smaller and smaller parts until it got to an achievable size. Due to the lack of tools he first encountered moving into the Apple ecosystem, Gio researched and experimented with testing strategies and tools document in an ongoing project that catalogued on his blog and in talks and workshops at various industry conferences.