100% found this document useful (3 votes)
239 views

Download ebooks file iOS Test Driven Development by Tutorials First Edition Learn Real World Test Driven Development Joshua Greene all chapters

Development

Uploaded by

marekreccakv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
239 views

Download ebooks file iOS Test Driven Development by Tutorials First Edition Learn Real World Test Driven Development Joshua Greene all chapters

Development

Uploaded by

marekreccakv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download the Full Version of textbook for Fast Typing at textbookfull.

com

iOS Test Driven Development by Tutorials First


Edition Learn Real World Test Driven Development
Joshua Greene

https://textbookfull.com/product/ios-test-driven-
development-by-tutorials-first-edition-learn-real-world-
test-driven-development-joshua-greene/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Test Driven Java Development 1st Edition Farcic Viktor


Garcia Alex

https://textbookfull.com/product/test-driven-java-development-1st-
edition-farcic-viktor-garcia-alex/

textboxfull.com

Test Driven JavaScript Development 1st Edition Gupta Ravi


Kumar Prajapati Hetal Singh Harmeet

https://textbookfull.com/product/test-driven-javascript-
development-1st-edition-gupta-ravi-kumar-prajapati-hetal-singh-
harmeet/
textboxfull.com

Test Driven Java Development Invoke TDD principles for end


to end application development 2nd Edition Alex Garcia

https://textbookfull.com/product/test-driven-java-development-invoke-
tdd-principles-for-end-to-end-application-development-2nd-edition-
alex-garcia/
textboxfull.com

Test-Driven Development in Go: A practical guide to


writing idiomatic and efficient Go tests through real-
world example 1st Edition Adelina Simion
https://textbookfull.com/product/test-driven-development-in-go-a-
practical-guide-to-writing-idiomatic-and-efficient-go-tests-through-
real-world-example-1st-edition-adelina-simion/
textboxfull.com
Thoughtful machine learning with Python a test driven
approach First Edition Kirk

https://textbookfull.com/product/thoughtful-machine-learning-with-
python-a-test-driven-approach-first-edition-kirk/

textboxfull.com

Python Testing Cookbook Easy solutions to test your Python


projects using test driven development and Selenium 2nd
Edition Greg L. Turnquist & Bhaskar N. Das
https://textbookfull.com/product/python-testing-cookbook-easy-
solutions-to-test-your-python-projects-using-test-driven-development-
and-selenium-2nd-edition-greg-l-turnquist-bhaskar-n-das/
textboxfull.com

Test Driven Development in Ruby A Practical Introduction


to TDD Using Problem and Solution Domain Analysis Paranj

https://textbookfull.com/product/test-driven-development-in-ruby-a-
practical-introduction-to-tdd-using-problem-and-solution-domain-
analysis-paranj/
textboxfull.com

Design Patterns by Tutorials Learning design patterns in


Swift 4 2 Joshua Greene

https://textbookfull.com/product/design-patterns-by-tutorials-
learning-design-patterns-in-swift-4-2-joshua-greene/

textboxfull.com

Test Driven Development with Python Obey the Testing Goat


Using Django Selenium and JavaScript 2nd Edition Harry J.
W. Percival
https://textbookfull.com/product/test-driven-development-with-python-
obey-the-testing-goat-using-django-selenium-and-javascript-2nd-
edition-harry-j-w-percival/
textboxfull.com
iOS Test-Driven Development by Tutorials

iOS Test-Driven Development by Tutorials


By Joshua Greene & Michael Katz

Copyright ©2019 Razeware LLC.

No7ce of Rights
All rights reserved. No part of this book or corresponding materials (such as text,
images, or source code) may be reproduced or distributed by any means without
prior written permission of the copyright owner.

No7ce of Liability
This book and all corresponding materials (such as source code) are provided on an
“as is” basis, without warranty of any kind, express of implied, including but not
limited to the warranties of merchantability, fitness for a particular purpose, and
noninfringement. In no event shall the authors or copyright holders be liable for any
claim, damages or other liability, whether in action of contract, tort or otherwise,
arising from, out of or in connection with the software or the use of other dealing in
the software.

Trademarks
All trademarks and registered trademarks appearing in this book are the property of
their own respective owners.

raywenderlich.com 2
iOS Test-Driven Development by Tutorials

Dedica7ons
"For my girls. I love you very much."

— Joshua Greene

"Dedicated to the memory of my mother-in-law, Barbara


Schwartz. Her selflessness and dedication to teaching inspires
me to give back to the community and educate others."

— Michael Katz

raywenderlich.com 3
iOS Test-Driven Development by Tutorials

About the Authors


Joshua Greene is an author of this book. He's an experienced
software developer and has created many mobile apps. When he's
not slinging code, you can find him wandering the streets of Tokyo.
You can reach him on Twitter @jrg_developer.

Michael Katz is a champion baker. ;] Oh, he's also an author of this


book, developer, architect, speaker, writer and avid homebrewer.
He has contributed to several books on iOS development and is a
long-time member of the raywenderlich.com tutorial team. He's
currently serving as director of mobile engineering at Viacom. He
shares his home state of New York with his family, the world's best
bagels and the Yankees. When he's not at his computer, he's out on
the trails, in his shop or reading a good book (like this one!).

About the Editors


Darren Ferguson is the final pass editor for this book. He is an
experienced software developer and works for M.C. Dean, Inc, a
systems integration provider from North Virginia. When he's not
coding, you'll find him enjoying EPL Football, traveling as much as
possible and spending time with his wife and daughter.

Manda Frederick is the editor of this book. She has been involved
in publishing for over ten years through various creative,
educational, medical and technical print and digital publications,
and is thrilled to bring her experience to the raywenderlich.com
family as Managing Editor. In her free time, you can find her at the
climbing gym, backpacking in the backcountry, hanging with her
dog, working on poems, playing guitar and exploring breweries.

raywenderlich.com 4
iOS Test-Driven Development by Tutorials

Jeff Rames is a tech editor for this book. He’s an enterprise


software developer in San Antonio, Texas who's focused on iOS for
nearly a decade. He spends his free time with his wife and
daughters, except when he abandons them for trips to Cape
Canaveral to watch rocket launches. Say hi on Twitter @jefframes!

James Taylor is a tech editor for this book. He’s an iOS developer
living in San Antonio, Texas with both his wife and daughter. He
enjoys bicycle touring around the United States and spending way
too much time on YouTube. You can find him on Twitter
@jamestaylorios.

About the Ar7st


Vicki Wenderlich is the designer and artist of the cover of this
book. She is Ray’s wife and business partner. She is a digital artist
who creates illustrations, game art and a lot of other art or design
work for the tutorials and books on raywenderlich.com. When she’s
not making art, she loves hiking, a good glass of wine and
attempting to create the perfect cheese plate.

raywenderlich.com 5
iOS Test-Driven Development by Tutorials

Table of Contents: Overview


Introduc7on ..................................................................................... 14
What You Need .............................................................................. 17
Book License ................................................................................... 18
Book Source Code & Forums ...................................................... 20
Sec7on I: Hello, TDD! ..................................................... 22
Chapter 1: What Is TDD? .................................................. 23
Chapter 2: The TDD Cycle ................................................ 28
Sec7on II: Beginning TDD ............................................. 42
Chapter 3: TDD App Setup ............................................... 43
Chapter 4: Test Expressions .............................................. 63
Chapter 5: Test Expecta7ons ............................................ 89
Chapter 6: Dependency Injec7on & Mocks ................ 116
Sec7on III: TDD with Networking ............................ 140
Chapter 7: Introducing Dog Patch ................................ 141
Chapter 8: Networking client ......................................... 146
Chapter 9: Using the Network Client ........................... 174
Chapter 10: Image Client ................................................ 193
Sec7on IV: TDD in Legacy Apps ................................ 228
Chapter 11: Legacy Problems ........................................ 230
Chapter 12: Dependency Maps ..................................... 254
Chapter 13: Breaking Up Dependencies ..................... 270

raywenderlich.com 6
iOS Test-Driven Development by Tutorials

Chapter 14: Modularizing Dependencies .................... 290


Chapter 15: Adding Features to Exis7ng Classes ...... 307

raywenderlich.com 7
iOS Test-Driven Development by Tutorials

Table of Contents: Extended


Introduc7on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
About this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Sec7on introduc7ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
How to read this book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
What You Need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Book License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Book Source Code & Forums . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Sec7on I: Hello, TDD! . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Chapter 1: What Is TDD? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Why should you use TDD? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
What should you test? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
But TDD takes too long! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
When should you use TDD? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Chapter 2: The TDD Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Ge_ng started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Red: Write a failing test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Green: Make the test pass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Refactor: Clean up your code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Repeat: Do it again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
TDDing init(availableFunds:) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
TDDing addItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Adding two items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Challenge. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Sec7on II: Beginning TDD . . . . . . . . . . . . . . . . . . . . . . 42

raywenderlich.com 8
iOS Test-Driven Development by Tutorials

Chapter 3: TDD App Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43


About the FitNess app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Your first test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Red-Green-Refactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Test nomenclature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Structure of XCTestCase subclass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Your next set of tests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Using @testable import. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Tes7ng ini7al condi7ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Challenge. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Chapter 4: Test Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Assert methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
View controller tes7ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Test ordering mahers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Code coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Debugging tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Challenge. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Chapter 5: Test Expecta7ons. . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Using an expecta7on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Tes7ng for true asynchronicity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Wai7ng for no7fica7ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Showing the alert to a user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Ge_ng specific about no7fica7ons . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Driving alerts from the data model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Using other types of expecta7ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

raywenderlich.com 9
iOS Test-Driven Development by Tutorials

Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115


Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Chapter 6: Dependency Injec7on & Mocks . . . . . . . . . . . . . 116
What's up with fakes, mocks, and stubs? . . . . . . . . . . . . . . . . . . . . . . 116
Understanding CMPedometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Mocking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Handling error condi7ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Ge_ng actual data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Making a func7onal fake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Wiring up the chase view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Time dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

Sec7on III: TDD with Networking . . . . . . . . . . . . . . 140


Chapter 7: Introducing Dog Patch . . . . . . . . . . . . . . . . . . . . . 141
Ge_ng started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Understanding Dog Patch's architecture . . . . . . . . . . . . . . . . . . . . . . . 144
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Chapter 8: Networking client . . . . . . . . . . . . . . . . . . . . . . . . . 146
Ge_ng Started. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Se_ng up the networking client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
TDDing the networking call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Dispatching to a response queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Chapter 9: Using the Network Client . . . . . . . . . . . . . . . . . . 174
Ge_ng started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Crea7ng a shared instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Adding a network client property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

raywenderlich.com 10
iOS Test-Driven Development by Tutorials

Using the network client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178


Crea7ng the network client protocol . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Crea7ng the mock network client . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Using the mock network client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Chapter 10: Image Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Ge_ng started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Se_ng up the image client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Crea7ng an image client protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Downloading an image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Se_ng an image view from a URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Using the image client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

Sec7on IV: TDD in Legacy Apps . . . . . . . . . . . . . . . . 228


Chapter 11: Legacy Problems . . . . . . . . . . . . . . . . . . . . . . . . . 230
Introducing MyBiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Iden7fying a change point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Finding a test point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Breaking dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Wri7ng tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Making a change and refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Chapter 12: Dependency Maps . . . . . . . . . . . . . . . . . . . . . . . 254
Ge_ng started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Choosing where to begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Finding direct dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Finding secondary dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

raywenderlich.com 11
iOS Test-Driven Development by Tutorials

Deciding when to stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263


What are problema7c dependencies? . . . . . . . . . . . . . . . . . . . . . . . . . 264
Finding problema7c dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Comple7ng the map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Breaking up complex systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Key Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Chapter 13: Breaking Up Dependencies . . . . . . . . . . . . . . . . 270
Ge_ng started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Characterizing the system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Breaking up the API/AppDelegate dependency . . . . . . . . . . . . . . . . . 274
Breaking the AppDelegate dependency . . . . . . . . . . . . . . . . . . . . . . . 279
Breaking the ErrorViewController dependency . . . . . . . . . . . . . . . . . 282
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Key Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Chapter 14: Modularizing Dependencies . . . . . . . . . . . . . . . 290
Moving files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Using the new framework with Login . . . . . . . . . . . . . . . . . . . . . . . . . 296
Fixing MyBiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Wrap up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Chapter 15: Adding Features to Exis7ng Classes . . . . . . . . 307
Ge_ng started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Sending reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
Adding analy7cs to the view controllers . . . . . . . . . . . . . . . . . . . . . . . 315
Passing around dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

raywenderlich.com 12
iOS Test-Driven Development by Tutorials

Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323


Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

raywenderlich.com 13
I Introduc7on

Welcome to iOS Test-Driven Development by Tutorials! This book will teach you all
about test-driven development (TDD) — the art of turning requirements into tests
and tests into production code.

You'll get hands-on TDD experience by creating three real-world apps in this book:

By the end of this book, you'll have a strong understanding of TDD and be able to
apply this knowledge to your own apps.

raywenderlich.com 14
iOS Test-Driven Development by Tutorials Introduction

About this book


We wrote this book with beginner-to-intermediate developers in mind. The only
requirements for reading this book are a basic understanding of Swift and iOS
development.

If you’ve worked through our classic beginner books — the Swift Apprentice https://
store.raywenderlich.com/products/swift-apprentice and the iOS Apprentice https://
store.raywenderlich.com/products/ios-apprentice — or have similar development
experience, you’re ready to read this book. You'll also benefit from a working
knowledge of design patterns — such as working through Design Patterns by Tutorials
https://store.raywenderlich.com/products/design-patterns-by-tutorials — but this
isn't strictly required.

As you work through this book, you’ll progress from beginner topics to more
advanced concepts.

Sec7on introduc7ons
I. Introduc7on
This is a high-level introduction to TDD, explaining why it's important and how it
will help you.

You'll also be introduced to the TDD Cycle in this section. This is the foundation for
how TDD works and guiding principles on the best way to apply it.

II. Beginning TDD


You'll learn the basics of TDD in this section, including XCTest, test expressions,
mocks and test expectations.

The chapters in this section build an example app called Fitness. This is the premier
fitness-coaching app based on the "Loch Ness" workout: You'll have to outrun,
outswim and outclimb Nessie (or get eaten)!

raywenderlich.com 15
iOS Test-Driven Development by Tutorials Introduction

III. TDD with Networking


You'll learn about TDD and networking in this section, including writing tests for
RESTful networking calls, downloading images and using networking clients.

You'll create an app called Dog Patch throughout this section. Dog Patch lets dog
lovers everywhere connect with kind breeders to help get the dog of their dreams.

IV. TDD in Legacy Apps


This section will teach you how to start TDD in a legacy app that wasn't created with
TDD and doesn't have sufficient test coverage.

You'll update an app called MyBiz throughout this section. MyBiz is an enterprise
resource planning (ERP) app for running a business, including employee
management and scheduling, time tracking, payroll and inventory management.

How to read this book


If you're new to unit testing or TDD, you should read this book from cover to cover.

If you already have some experience with TDD, you can skip from chapter to chapter
or use this book as a reference. You'll always be provided with a starter project in
each chapter to get up and running quickly.

What's the absolute best way to read this book? Just start reading wherever makes
sense to you!

raywenderlich.com 16
W What You Need

To follow along with this book, you'll need the following:

• Xcode 11 or later. Xcode is the main development tool for writing code in Swift.
You need Xcode 11 at a minimum, since that version includes Swift 5.1. You can
download the latest version of Xcode for free from the Mac App Store, here:
apple.co/1FLn51R.

If you haven't installed the latest version of Xcode, be sure to do that before
continuing with the book. The code covered in this book depends on Swift 5.1 and
Xcode 11 — the code may not compile if you try to work with an older version.

raywenderlich.com 17
L Book License

By purchasing iOS Test-Driven Development by Tutorials, you have the following


license:

• You are allowed to use and/or modify the source code in iOS Test-Driven
Development by Tutorials in as many apps as you want, with no attribution
required.

• You are allowed to use and/or modify all art, images and designs that are included
in iOS Test-Driven Development by Tutorials in as many apps as you want, but must
include this attribution line somewhere inside your app: “Artwork/images/designs:
from iOS Test-Driven Development by Tutorials, available at
www.raywenderlich.com”.

• The source code included in iOS Test-Driven Development by Tutorials is for your
personal use only. You are NOT allowed to distribute or sell the source code in iOS
Test-Driven Development by Tutorials without prior authorization.

• This book is for your personal use only. You are NOT allowed to sell this book
without prior authorization, or distribute it to friends, coworkers or students; they
would need to purchase their own copies.

All materials provided with this book are provided on an “as is” basis, without
warranty of any kind, express or implied, including but not limited to the warranties
of merchantability, fitness for a particular purpose and noninfringement. In no event
shall the authors or copyright holders be liable for any claim, damages or other
liability, whether in an action or contract, tort or otherwise, arising from, out of or in
connection with the software or the use or other dealings in the software.

raywenderlich.com 18
iOS Test-Driven Development by Tutorials Book License

All trademarks and registered trademarks appearing in this guide are the properties
of their respective owners.

raywenderlich.com 19
B Book Source Code &
Forums

If you bought the digital edi7on


The digital edition of this book comes with the source code for the starter and
completed projects for each chapter. These resources are included with the digital
edition you downloaded from https://store.raywenderlich.com/products/ios-test-
driven-development.

If you bought the print version


You can get the source code for the print edition of the book here:

• https://store.raywenderlich.com/products/ios-test-driven-development-source-
code

Forums
We’ve also set up an official forum for the book at forums.raywenderlich.com.This is
a great place to ask questions about the book or to submit any errors you may find.

Digital book edi7ons


We have a digital edition of this book available in both ePUB and PDF, which can be
handy if you want a soft copy to take with you, or you want to quickly search for a
specific term within the book.

raywenderlich.com 20
iOS Test-Driven Development by Tutorials Book Source Code & Forums

Buying the digital edition version of the book also has a few extra benefits: free
updates each time we update the book, access to older versions of the book, and you
can download the digital editions from anywhere, at anytime.

Visit our iOS Test-Driven Development store page here:

• https://store.raywenderlich.com/products/ios-test-driven-development.

And if you purchased the print version of this book, you’re eligible to upgrade to the
digital editions at a significant discount! Simply email [email protected] with
your receipt for the physical copy and we’ll get you set up with the discounted digital
edition version of the book.

raywenderlich.com 21
Sec7on I: Hello, TDD!

This section is a high-level introduction to test-driven development, how it works


and why you should use it. You'll also learn about the TDD cycle in this chapter, and
you'll use this throughout the rest of the book.

• Chapter 1: What Is TDD?: Test-driven development, or TDD, is an iterative way


to develop software by making many small changes backed by tests.

• Chapter 2: The TDD Cycle: TDD has four steps known as the Red-Green-
Refactor Cycle.

raywenderlich.com 22
1 Chapter 1: What Is TDD?
By Joshua Greene

Test-driven development, or TDD, is an iterative way to develop software by


iteratively making many small changes backed by tests.

It has four steps:

1. Write a failing test

2. Make the test pass

3. Refactor

4. Repeat

This is called the TDD Cycle. It ensures you thoroughly and accurately test your
code because your development is... driven by testing!

raywenderlich.com 23
iOS Test-Driven Development by Tutorials Chapter 1: What Is TDD?

By writing a test followed by the production code to make it pass, you ensure your
production code is testable and that it meets all of your requirements during
development. As an added bonus, your tests act as documentation for your
production code, describing how it works.

On the surface, the TDD process seems pretty simple. Well, I’m sorry to tell you
that... wait, it actually is really simple!

Sure, there are special circumstances for how to implement this cycle at times, but
that’s where this book comes in! Once you get the hang of this process, it will
become second nature. You’ll learn a lot more about this process in the next chapter.

Why should you use TDD?


TDD is the single best way to ensure your software works and continues to work well
into the future — well, that’s quite a bold claim! Let me explain.

It’s hard to argue against testing your code, but you don’t have to follow TDD to do
this. For example, you could write all of your production code and then write all of
your tests. Alternatively, you could skip writing tests altogether and, instead,
manually test your code. Why is TDD better than these options?

Good tests ensure your app works as expected. However, not all tests are "good."
Writing tests for the sake of having tests isn’t a worthwhile exercise. Rather, good
tests are failable, repeatable, quick to run and maintainable.

TDD provides methodology that ensures your tests are good:

• The first step is to write a failing test. By definition, this proves the test is failable.
Tests that can’t fail aren’t very useful. Rather, they waste valuable CPU time.

• Before you’re allowed to write a new test, all other previous tests must pass. This
ensures that your tests are repeatable: You don’t just run the single test you’re
working on, but rather, you constantly run all of the tests.

• By frequently running every test, you’re incentivized to make sure tests are quick
to run. All of your tests should take seconds to run — preferably, one second or
less.

A single test that takes a hundred milliseconds is too slow: After only ten tests,
your entire test suite will take one second to run. After fifty tests, it takes five
seconds. After several seconds, no one runs all of the tests because it takes too
long.

raywenderlich.com 24
iOS Test-Driven Development by Tutorials Chapter 1: What Is TDD?

• When you refactor, you update both your production and test code. This ensures
your tests are maintained: You’re constantly keeping them up-to-date.

• By iteratively writing production code and tests in parallel, you ensure your code is
testable. If you were to write tests after completing the code, it’s likely the
production code would require quite a bit of refactoring to fully unit test.

Nonetheless, the devil’s advocate in you may say, "But you could write good tests
without following TDD." You definitely could, but you may struggle to succeed. You
can definitely do it in the short term, but it’s much more difficult in the long term.
You’d need to be disciplined about writing good tests. Before long, you’d likely create
some sort of system to ensure that you’re writing good tests... you’d likely find
yourself doing a variant of TDD!

What should you test?


Better test coverage doesn’t always mean your app is better tested. There are things
you should test and others you shouldn’t. Here are the do’s and don’ts:

• Do write tests for code that can’t be caught in an automated fashion otherwise.
This includes code in your classes’ methods, custom getters and setters and most
anything else you write yourself.

• Don’t write tests for generated code. For example, it’s not worthwhile to write
tests for generated getters and setters. Swift does this very well, and you can trust
it works.

• Don’t write tests for issues that can be caught by the compiler. If the tested issue
would generate an error or warning, Xcode will catch it for you.

• Don’t write tests for dependency code, such as first- or third-party frameworks
your app uses. The framework authors are responsible for writing those tests. For
example, you shouldn’t write tests for UIKit classes because UIKit developers are
responsible for writing these. However, you should write tests for your custom
subclasses thereof: This is your custom code, so you’re responsible for writing the
tests.

An exception to the above is writing tests in order to determine how a framework


works. This can be very useful to do. However, you don’t need to keep these tests
long term. Rather, you should delete them afterwards.

Another exception is "sanity tests" that prove third-party code works as you expect.
These sort of tests are useful if the library isn’t fully stable, or you don’t trust it

raywenderlich.com 25
iOS Test-Driven Development by Tutorials Chapter 1: What Is TDD?

entirely. In either case, you should really scrutinize whether or not you want to use
the library at all — is there a better option that’s more trustworthy?

But TDD takes too long!


The most common complaint about TDD is that it takes too long — usually followed
by exclamation point(s) or sad-face emojis.

Fortunately, TDD gets faster once you get used to doing it. However, the truth is that
compared to not writing any tests at all, you’re writing more code ultimately. It likely
will take a little more time to develop initially.

That said, there’s a really big hole in this argument: The real time cost of
development isn’t just writing the initial, first-version production code. It also
includes adding new features over time, modifying existing code, fixing bugs and
more. In the long run, following TDD takes much less time than not following it
because it yields more maintainable code with fewer bugs.

There’s also another cost to consider: customer impact of bugs in production. The
longer an issue goes undiscovered, the more expensive it is. It can result in negative
reviews, lost trust and lost revenue.

If an issue is caught during development, it’s easier to debug and quicker to fix. If
you discovered it weeks later, you’d spend substantially more time getting up to
speed on the code and tracking down the root cause. By following TDD, your tests
ultimately help safeguard and protect your app against bugs.

When should you use TDD?


TDD can be used during any point in a product’s life cycle: new development, legacy
apps and everything in between. However, how and where you start TDD does
depend on the state of your project. This book will cover how to approach many of
these situations!

However, an important question to ask: Should your project use TDD at all?

As a general rule of thumb, if your app is going to last more than a few months, will
have multiple releases and/or require complex logic, you’re likely better off using
TDD than not.

raywenderlich.com 26
iOS Test-Driven Development by Tutorials Chapter 1: What Is TDD?

If you’re creating an app for a hackathon, test project or something else that’s meant
to be temporary, you should evaluate whether TDD makes sense. If there’s really only
going to be one version of the app, you might not follow TDD or might only do TDD
for critical or difficult parts.

Ultimately, TDD is a tool, and it’s up to you to decide when it’s best to use it!

Key points
In this chapter, you learned what TDD is, why you should use it, what to test and
when to use it. Here are the key points to remember:

• TDD offers a consistent method to write good tests.

• Goods tests are failable, repeatable, quick to run and maintainable.

• Write tests for code that you’re responsible for maintaining. Don’t test code that’s
automatically generated or code within dependencies.

• The real cost of development includes initial coding time, adding new features
over time, modifying existing code, fixing bugs and more. TDD reduces
maintenance costs and quantity of bugs, often making it the most cost effective
approach.

• TDD is most useful for long-term projects lasting more than a few months or
having multiple releases.

raywenderlich.com 27
2 Chapter 2: The TDD Cycle
By Joshua Greene

In the previous chapter, you learned that test-driven development boils down to a
simple process called the TDD Cycle. It has four steps that are often "color coded" as
follows:

1. Red: Write a failing test, before writing any app code.

2. Green: Write the bare minimum code to make the test pass.

3. Refactor: Clean up both your app and test code.

4. Repeat: Do this cycle again until all features are implemented.

This is also called the Red-Green-Refactor Cycle.

raywenderlich.com 28
iOS Test-Driven Development by Tutorials Chapter 2: The TDD Cycle

Why is it color coded? This corresponds to the colors shown in most code editors,
including Xcode:

• Failing tests are indicated with a red X.

• Passing tests are shown with a green checkmark.

This chapter provides an introduction to the TDD Cycle, which you'll use throughout
the rest of this book. However, it doesn't go into detail about test expressions
(XCTAssert, et al.) or how to set up a test target. Rather, these topics are covered in
later chapters. For now, focus on learning the TDD Cycle, and you'll learn the rest as
you go along.

It's best to learn by doing, so let's jump straight into code!

GeXng started
In this chapter, you'll create a simple version of a cash register to learn the TDD
Cycle. To keep the focus on TDD instead of Xcode setup, you'll use a playground.
Open CashRegister.playground in the starter directory, then open the
CashRegister page. You'll see this page has two imports, but otherwise it's empty.

Naturally, you'll begin with the first step in the TDD Cycle: red.

Red: Write a failing test


Before you write any production code, you must first write a failing test. To do so,
you need to create a test class. Add the following below the import statements:

class CashRegisterTests: XCTestCase {

Above, you declare CashRegisterTests as a subclass of XCTestCase, which is part


of the XCTest framework. You'll almost always subclass XCTestCase to create your
test classes.

raywenderlich.com 29
Another Random Scribd Document
with Unrelated Content
Murphy, T. J.

1919. Postinfluenzal tuberculosis. Boston Med. and Surg.


Jour., CLXXXI, 266.

Netter, A.

1918. L’épidémie d’influenza de 1918. Paris Médical, Nov. 16,


1918, 382.

Newsholme, A.

1920. Influenza. A discussion. Longmans, Green & Co., CII,


80.
1907. Influenza from a public health standpoint. Practitioner,
118.
1919. Jour. Am. Med. Ass., LXXIII, 890.
1919. Influenza from a public health standpoint. Practitioner,
CII, 6.

Niemann and Foth.

1919. Deutsche Med. Woch., XLV, 471.

Office International d’Hygiène Publique.

1918. X, also Jan. and Feb., 1920, XII.

Opie, Freeman, Blake, Small and Rivers.

1919. Pneumonia at Camp Funston. Report to Surgeon


General. Jour. Am. Med. Ass., LXXII, 108.
1919. Pneumonia following influenza at Camp Pike, Ark. Ibid.,
556.

Orticoni, A., Barbié and Angé.

1919. Pathogenesis of influenza. Abst. in Jour. Am. Med. Ass.,


LXXIII, 69.

Ovazza, V. E.

1919. Prophylaxis of influenza. Abst. in Jour. Am. Med. Ass.,


LXXII, 1335.

Parkes, Edmund A.

1876. “Influenza” in Reynolds’ System of Medicine. I, 28.

Parsons, H. Franklin.

1893. Local Government Board Reports. C–6387 (1891) and


C–7051 (1893).
1893. A further report on the influenza epidemics of 1889–90,
1891 and 1891–92. Local Government edition. London,
1893.

Parsons, H. C.

1919. Official report on the influenza epidemic 1918. Canad.


Med. Ass. Jour., Toronto, IX, 351.

Pearl, Raymond.

1919. On certain general statistical aspects in the 1918


epidemic in American cities. Public Health Reports, Aug.
8, 1919.

Peck, J. H.

1920. Relation of influenza to tuberculosis. Iowa State Med.


Soc. Jour., X, 42.

Péhu, M. and Ledoux, E.

1918. Revue documentaire sur l’épidémie actuelle de grippe en


France. Ann. de Med., V, 579.

Pneumonic Plague.

1918. China Med. Jour., XXXII, 146.

Pollard, R.

1920. Control of influenza. Brit. Med. Jour., I, 258.

Pruvost, E.

1919. Considérations inspirées par la récente épidémie de


grippe sur la pathogénie de cette maladie et sur celle de
la tuberculose. Bull. et Mém. Soc. Méd. des Hôp. de
Paris, 3 s., XLIII, 783.

Raffelt, F.

1920. Influenza Epidemie, 1918. Wien. klin. Woch., XXXIII,


April 15.

Renon, L. and Mignot, R.


1920. La grippe de 1920 a l’hôpital Necker. Bull, et Mém. Soc.
Med. des Hôp. de Paris, 509.

Prevention Bureau.

1918. Report of the Shansi Plague. China Med. Jour., XXXII,


559.

Roussy, B.

1919. Nature et modes d’action de l’agent, pathogène


infectieux de la grippe ou influenza. Rev. d’hyg., XLI,
104.

Rose, F. G.

1919. The influenza epidemic in British Guiana. Lancet, I, 421.

Rosenau, M. J.

1919. Experiments to determine the mode of spread of


influenza. Jour. Am. Med. Ass., LXXIII, 311.

Rosenow, E. C.

1919. Prophylactic inoculation against respiratory infections.


Jour. Am. Med. Ass., LXXII, 31.

Roys, Chas. K.

1918. Report on epidemic of pneumonic plague in Tsinauflu,


1918. China Med. Jour., XXXII, 346.

Ruhräh, J.
1919. Some of the aspects of epidemic influenza in children.
Med. Clin. North Am., II, 1597.

Russell, W.

1919. Some aspects of the influenza epidemic. Lancet, I, 690.

Robertson, Jno. D., and Koehler, Gottfried.

1918. Preliminary report on the influenza epidemic in


Chicago. Am. Jour. Pub. Health, VIII, 849.

Rondopoulos, P. J.

1919. Influenza in Greece. Abstr. in Jour. Am. Med. Ass.,


LXXII, 1947.

Sahli, H.

1919. Influenza. Abstr. in Jour. Am. Med. Ass., Ibid., 687.

Sanz, E. F.

1919. Jacksonian epilepsy following influenza. Abstr. in Jour.


Am. Med. Ass., LXXIII, 73.

Schofield, F. W. and Cynn, H. C.

1919. Pandemic influenza in Korea. Jour. Am. Med. Ass.,


LXXII, 981.

Scoccia, V.
1919. Does influenza confer immunity? Abstr. in Jour. Am.
Med. Ass. Ibid., 529.

Selter, H.

1918. Zur Aetiologie der Influenza. Deutsch. Med. Woch,


XLIV, 932.

Sherman, C. L.

1913. Common infections that are often erroneously


diagnosed as grip. Jour. Am. Med. Ass., LXI, 1567.

Siciliano, L.

1919. Qualche osservazione sull’epidemiologia dell’influenza.


Riv. crit. di Clin. Med. Firenze, XX, 97.

Silvestri, I.

1919. Quinine, malaria and influenza. Abst. in Jour. Am. Med.


Ass., LXXIII, 304.

Small, W. D. D.

1920. Clinical features, etiology and treatment of influenza.


Edinb. Med. Jour., XXV, 15.

Smith, Theobald.

1904. Some problems in the life history of pathogenic


microorganisms. Am. Med., 711.

Soldan, C. E.
1919. Influenza in Lima. Abstr. in Jour. Am. Med. Ass., LXXII,
970.

Soper, George A.

1919. The influenza-pneumonia pandemic in the American


Army camps during September and October, 1918.
Science, N. S., XLVIII, 451.
1919. The efficiency of existing measures for the prevention of
disease. Jour. Am. Med. Ass., LXXIII, 1405.
1919. What is influenza? Boston Med. and Surg. Jour.,
CLXXXI, 635.
1919. Influenza in horses and in man. N. Y. Med. Jour., CIX,
270.

Spear, B. E.

1920. The periodicity of influenza. Lancet, I, 889.

Spooner, L. H., Scott, J. M. and Heath, E. H.

1919. A bacteriologic study of the influenza epidemic at Camp


Devens, Mass. Jour. Am. Med. Ass., LXXII, 155.

Stallybrass, C. O.

1920. The periodicity of influenza. Lancet, CXCVIII, 372.

Stanley, Arthur.

1918. Notes on pneumonic plague in China. China Med. Jour.,


XXXII, 207.
Stanley, L. L.

1919. Influenza at San Quentin Prison, California. Public


Health Reports, XXXIV, 996.

Stivelman, B.

1919. Effects of influenza on pulmonary tuberculosis. New


York Med. Jour., LX, 20.

Sturrock.

1905. Notes on an epidemic of influenza, occurring in the


Midlothian and Peebles Asylums. Brit. Med. Jour.

Sydenstricker, Edgar.

1920. Difficulties in computing civil death rates for 1918 with


especial reference to epidemic influenza. Public Health
Reports, XXXV, 330.
1918. Preliminary statistics of the influenza epidemic. Public
Health Reports, XXXIII, 2305.

Teissier, J.

1920. La grippe parallèle des deux grandes pandémies de 1889


et de 1918. Paris Méd., XXXV, 69.

Telling, W. H. M. and Hann, R. G.

1913. Influenza with repeated rigors. Practitioner, 764.

de los Terroros, C. S.
1919. Influenza in children. Abstr. in Jour. Am. Med Ass.,
LXXII, 764.

Topley, W. W. C.

1919. The spread of bacterial infection. Lancet, II, 1, 45, 91.

Ustvedt, Y.

1919. Influenza in Norway. Abstr. in Jour. Am. Med. Ass.,


LXXII, 1115.

Vaughan, Henry F.

1920. Influenza in Detroit. Weekly health reports,


Commissioner of Health, Detroit.

Vaughan, V. C.

1918. An explosive epidemic of influenzal disease at Fort


Oglethorpe. Jour. Lab. and Clin. Med., III, 560.
1918. The influenza in Germany, Ibid., IV, 83.
1918. Notes on influenza. Ibid., 145.
1918. Influenza and pneumonia at Brest, France. Ibid., 223.
1918. Influenza at Camp Custer. Ibid., 225.
1918. Influenza and pneumonia at Camp Grant. Ibid., 306.
1918. Notes on influenza. Ibid., 309.
1918. Encephalitis lethargica. Ibid., 381.
1919. Jour. Am. Med. Ass., LXXIII, 890.

Vaughan, V. C. and Palmer, Geo. T.


1919. Communicable diseases in the United States Army
during the summer and autumn of 1918. Jour. Lab. and
Clin. Med., IV, 586.
1918. Communicable diseases in the National Guard and
National Army of the United States during the six
months from Sept. 29, 1917, to March 29, 1918. Jour.
Lab. and Clin. Med., III, 635.

Vaughan, W. T. and Schnabel, T. G.

1919. Pneumonia and empyema at Camp Sevier. Arch. Int.


Med., XXII, 441.

Vaughan, W. T.

1918. Clinical manifestations of empyema. Jour. Lab. and


Clin. Med., IV, 123.

Vico, G.

1919. Quinine and influenza. Abstr. in Jour. Am. Med. Ass.,


LXXII, 1648.

Wadsworth, A. B.

1919. Results of preventive vaccination with suspensions of


the influenza bacillus. Abstr. in Jour. Am. Med. Ass.,
LXXIII, 368.

Wahl, H. R., White, B. and Lyall, H. W.

1919. Some experiments in the transmission of influenza.


Jour. Inf. Dis., XXV, 419.
Walb.

1913. Pneumococcus influenza. Deutsch. Med. Woch., XXXIX.

Wallace, Geo. L.

1919. Report of the influenza epidemic and experience in the


use of influenza vaccine “B” at the Wrentham State
School. Boston Med. and Surg. Jour., CLXXX, 447.

Watson, Thomas.

1872. Principles and Practice of Physic. II, 71.

Watson, Percy T.

1919. The epidemic in Shansi; pneumonic plague or influenza?


China Med. Jour., XXXIII, 169.

Webster, J. O.

1871. Report of an epidemic of influenza. Boston Med. and


Surg. Jour., N. S., VII, 377.

Winslow, C. E. A. and Rogers, J. F.

1920. Statistics of the 1918 epidemic of influenza in


Connecticut. Jour. Infect. Dis., XXVI.

Wollstein, M. and Goldbloom, A.

1919. Epidemic influenza in infants. Am. Jour. Dis. of


Children, XVII, 165.
Woodward, Wm. C.

1918. Influenza in Boston. Monthly Bull, of the Health Dept,


of the City of Boston, VII, 179–186, 205–208, and VIII,
10.

Wooley, Paul G.

1918. The epidemic of influenza at Camp Devens, Mass. Jour.


Lab. and Clin. Med., IV, 330.
1919. An epidemiologic fragment. Med. Quart., Ottawa, I, 325.

Zinsser, H., Brooks, H., et al.

1920. Manifestations of influenza during the earlier periods of


its appearance in France. Med. Rec., XCVII, 459.

Zinsser, Hans.

Influenza. Oxford Medical Papers (to be published).


A most comprehensive bibliography of the literature covering the
epidemiology of influenza up until 1896 is to be found in
Leichtenstern’s original monograph.
APPENDIX

Form A.—Household record, used in Boston influenza census.


(See page 127.)

Form A.—(Continued.)
Form B.—Individual Record obtained for each person in every
family canvassed, whether the individual gave a history of
influenza (1918 or 1920) or not. (See page 127.)

Form B.—(Continued.)
TRANSCRIBER’S NOTES
1. Silently corrected obvious typographical errors and
variations in spelling.
2. Retained archaic, non-standard, and uncertain spellings
as printed.
*** END OF THE PROJECT GUTENBERG EBOOK INFLUENZA ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright
in these works, so the Foundation (and you!) can copy and
distribute it in the United States without permission and without
paying copyright royalties. Special rules, set forth in the General
Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree to
abide by all the terms of this agreement, you must cease using
and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project
Gutenberg™ works in compliance with the terms of this
agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms
of this agreement by keeping this work in the same format with
its attached full Project Gutenberg™ License when you share it
without charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it
away or re-use it under the terms of the Project Gutenberg
License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country where
you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of the
copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like