ebook img

Agile Swift: Swift Programming Using Agile Tools and Techniques PDF

179 Pages·2017·5.458 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Agile Swift: Swift Programming Using Agile Tools and Techniques

Agile Swift Swift Programming Using Agile Tools and Techniques — Godfrey Nolan Agile Swift Swift Programming Using Agile Tools and Techniques Godfrey Nolan Agile Swift: Swift Programming Using Agile Tools and Techniques Godfrey Nolan Huntington Woods, Michigan, USA ISBN-13 (pbk): 978-1-4842-2101-3 ISBN-13 (electronic): 978-1-4842-2102-0 10.1007/978-1-4842-2102-0 Library of Congress Control Number: 2016961810 Copyright © 2017 by Godfrey Nolan This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Lead Editor: Aaron Black Technical Reviewer: Bruce Wade Editorial Board: Steve Anglin, Pramila Balan, Laura Berendson, Aaron Black, Louise Corrigan, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal, James Markham, Susan McDermott, Matthew Moodie, Natalie Pao, Gwenan Spearing Coordinating Editor: Jessica Vakili Copy Editor: Kezia Endsley Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. Any source code or other supplementary materials referenced by the author in this text are available to readers at www.apress.com. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/. Readers can also access source code at SpringerLink in the Supplementary Material section for each chapter. Printed on acid-free paper Contents at a Glance About the Author ������������������������������������������������������������������������������ix About the Technical Reviewer ����������������������������������������������������������xi ■ Chapter 1: Introduction ������������������������������������������������������������������1 ■ Chapter 2: Swift Unit Testing ��������������������������������������������������������25 ■ Chapter 3: Third-Party Tools ���������������������������������������������������������61 ■ Chapter 4: Mocking ����������������������������������������������������������������������97 ■ Chapter 5: UI Testing ������������������������������������������������������������������117 ■ Chapter 6: Test Driven Development ������������������������������������������131 Index ����������������������������������������������������������������������������������������������169 iii Contents About the Author ������������������������������������������������������������������������������ix About the Technical Reviewer ����������������������������������������������������������xi ■ Chapter 1: Introduction ������������������������������������������������������������������1 Hello World Unit Test1 Benefits 2 Agile Testing Pyramid 3 Calculator Unit Tests in Xcode 3 Prerequisites4 Getting Started 5 Creating a Class 7 Setting Up the User Interface 10 Setting Up the Outlets 11 Create Unit Test Code 15 Run Unit Tests 15 Hello World Unit Test in Ubuntu 17 Prerequisites17 Create and Compile Code 18 Create Test Code 19 Ubuntu Tweaks 19 Run Unit Tests 20 v ■ Contents GUI Tests 21 Hello World GUI Test 21 Summary 23 ■ Chapter 2: Swift Unit Testing ��������������������������������������������������������25 Types of Assertions 25 XCTest Options 26 @testable 28 setUp 29 tearDown 30 Performance Testing 31 Calculator App 32 Creating the View 36 Completing the ViewController Code 41 Create the Model Code 42 Tests 43 Unit Testing 102 44 FIRST Unit Tests 44 Maintaining Your Unit Tests 45 Code Coverage 46 When Things Go Wrong 48 Logs 50 Ubuntu Command Line 52 Package Manager 54 Tests 55 Summary 60 vi ■ Contents ■ Chapter 3: Third-Party Tools ���������������������������������������������������������61 Fast Tests 61 Nimble Install 62 Nimble Unit Test 63 Isolated Unit Tests 64 Mocking 65 What Is Mocking 65 Repeatable Unit Tests 67 Installing Jenkins 68 Calculator Project 72 Self-Verifying Unit Tests 76 Slather 76 Technical Debt 78 Swift Lint 78 Swift Format 84 SonarQube 86 Stevia 93 Summary 95 ■ Chapter 4: Mocking ����������������������������������������������������������������������97 Same Rules Do Not Apply 97 Cuckoo 98 Mocking HTTP 101 Mocking User Defaults 104 Mocking Date and Time 108 Mocking System Settings 113 Summary 116 vii ■ Contents ■ Chapter 5: UI Testing ������������������������������������������������������������������117 Recording Tests 118 Coded Tests 121 Component Parts 122 Sample Test 124 Reporting 125 Summary 129 ■ Chapter 6: Test Driven Development ������������������������������������������131 Understanding Test Driven Development 131 Unit Testing versus TDD 132 Value of TDD 132 Writing an App Using TDD132 Feature 1 133 Feature 2 144 Feature 3 157 Conclusion 167 Index ����������������������������������������������������������������������������������������������169 viii About the Author Godfrey Nolan is founder and president of RIIS LLC, a mobile development firm in the Detroit Metro area. He is also the author of Agile Android, Bulletproof Android, Android Best Practices, Decompiling Android, and Decompiling Java. Godfrey has spoken at DroidCon and AnDevCon, as well as JavaOne, ASP-Connections, VSLive, CodeMash, Code PaLOUsa, 1DevDay, and many local Java and .NET user groups on a wide range of topics such as continuous integration, executable requirements, and mobile security. ix About the Technical Reviewer Bruce Wade is a software engineer from British Columbia, Canada. He started in software development when he was 16 years old by coding his first web site. He went on to study computer information systems at DeVry Institute of Technology in Calgary, then to further enhance his skills, he studied visual and game programming at The Art Institute, Vancouver. Over the years, he has worked for large corporations as well as for several start-ups. His software experience led him to utilize many technologies, including C/C++, Python, Objective-C, Swift, Postgres, and JavaScript. In 2012 he started the company, Warply Designed, to focus on mobile 2D/3D and OS X development. Aside from hacking out new ideas, he enjoys spending time hiking with his Boxer Rasco, working out, and exploring new adventures. xi

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.