33,59 €
Write testable and maintainable code to develop highly-functional iOS apps
My reader have already done some application development with Swift. They follow the changes in each new Swift version. They also follow a few Swift developers on Twitter or Tumblr and read blog post from famous Swift bloggers. My reader have already heard about Test-Driven Development (TDD) but haven't done really much about it. But they have heard/read that TDD can help to write better code but they don't really know why.
Test-driven development (TDD) is a proven way to find software bugs early. Writing tests before your code improves the structure and maintainability of your apps. In combination with the improved syntax of Swift 3, there is no excuse or writing bad code.
This book will help you understand the process of TDD and how it impacts your apps written in Swift. Through a practical, real-world example app, you'll start seeing how to implement TDD in context. You will begin with an overview of the TDD workflow and then deep dive into unit testing concepts and code cycles. You will also plan and structure your test driven iOS app, and write tests to drive the development of the view controllers and the helper classes. Next, you'll learn how to write tests for network code, what CI is and how to set it up using Xcode Server.
Finally, the book will guide you through the next steps to become a testing expert by discussing integration tests, Behavior Driven Development (BDD), open source testing frameworks and UI Tests introduced in Xcode 8.
Using a step-by-step approach, you will develop an entire iOS app using TDD. During the course of the book, you will experience different strategies to write tests for models, View Controller, and networking code.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 246
Veröffentlichungsjahr: 2016
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2016
Second edition: October 2016
Production reference: 1251016
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78712-907-8
www.packtpub.com
Author
Dr. Dominik Hauser
Copy Editor
Yesha Gangani
Reviewer
S Ravi Shankar
Project Coordinator
Sheejal Shah
Commissioning Editor
Ashwin Nair
Proofreader
Safis Editing
Acquisition Editor
Reshma Raman
Indexer
Rekha Nair
Content Development Editor
Parshva Sheth
Production Coordinator
Aparna Bhagat
Technical Editor
Rutuja Vaze
Dr. Dominik Hauser completed his Ph.D. from the University of Heidelberg in Physics. While working as a university professor, he started iOS development in his spare time. His first app on Physics has been an astounding success worldwide. Since then, he turned himself into a full-time iOS developer, crediting number of successful apps to his name. He has been a Swift developer since day one and runs a blog on iOS development, www.swiftandpainless.com.
I would like to thank my wife, Isa. Thank you for all your support during all those years and especially the last months while I wrote this book. I also want to thank all those great people in our community. I learned so much by reading excellent blog posts. I proud to be part of it.
S Ravi Shankar is a multi-skilled software consultant with over 17+ years of experience in IT Industry. Good all-around ability to work in different technologies and extensive experience in product development, system maintenance and support. A polyglot and a self-taught programmer with hands on experience in Swift, Objective-C and Java.
It was a pleasure to work with Sheejal and thanks to Packt publishing for giving me this opportunity.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
iOS projects have become bigger and more complex. Many projects have already surpassed desktop applications in their complexity. One important strategy to manage this complexity is through the use of unit tests. By writing tests, a developer can point out the intention of the code and provide a safety net against the introduction of bugs.
By writing the tests first (Test-Driven Development), the developer focuses on the problem. This way, they are forced to think about the domain and rephrase a feature request using their own understanding by writing the test. In addition to this, applications written using Test-Driven Development (TDD) only contain code that is needed to solve the problem.
As a result, the code is clearer, and the developer gains more confidence that the code actually works.
In this book, you will develop an entire iOS app using TDD. You will experience different strategies of writing tests for models, View Controller, and networking code.
Chapter 1, Your First Unit Tests, walks you through your first unit tests using Xcode and discusses the benefits of of using TDD.
Chapter 2, Planning and Structuring Your Test-Driven iOS App, introduces the app you are going to write through the course of this book and how to set up a project in Xcode.
Chapter 3, A Test-Driven Data Model, discusses the TDD of a data model.
Chapter 4, A Test-Driven View Controller, shows you how to write tests for View Controller, and describes how to use fake objects to isolate micro features for the test.
Chapter 5, Testing Network Code, teaches you to test network code using stubs to fake a server component before it is developed.
Chapter 6, Putting It All Together, walks you through the integration of all the different parts developed in previous chapters and shows the use of functional tests.
Chapter 7, Code Coverage and Continuous Integration, shows you how to measure the code coverage of your tests using Xcode and introduces you to continuous integration.
Chapter 8, Where to Go from Here, wraps up and shows you the possible next steps to improve your acquired testing skills.
The following hardware and software is needed to follow the code examples in the book:
If debugging iOS apps is a nerve-racking task for you and you are looking for a fix, this book is for you.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "To be able to write tests for your code, you need to import the module with the @testable keyword."
A block of code is set as follows:
func makeHeadline(string: String) -> String { return "This Is A Test Headline" }Any command-line input or output is written as follows:
ls -aNew terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "To edit the build scheme, click on Scheme in the toolbar in Xcode, and then click on Edit Scheme…."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Test-Driven-iOS-Development-with-Swift-3. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/B05912_TestDriveniOSDevelopmentwithSwift3SecondEdition_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at [email protected] with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
