Put into motion practical examples to master Test-Driven Development (TDD) and acceptance testing in Swift.
This book uses a pragmatic approach to writing well-tested code and provides techniques that can be used to retrofit tests to legacy code bases. You'll be introduced to basic principles of TDD, such as Test First, Red-Green-Refactor, Remove Duplicate code, Dependency Injection, and Single Responsibility. Approaches covered include TDD, behavior-driven development (BDD), UI, and acceptance testing with common standard/open source frameworks.
iOS Code Testing
offers helpful instruction to teach iOS developers to retrospectively fit tests to legacy code, refactor legacy code so as to make the code more testable, install and configure a popular Swift BDD framework, practice BDD with Xcode, and create automated UI tests with Xcode. Additionally, many projects have legacy code bases. Legacy code is often seen as a blocker when it comes to implementing any kind of testing. What You Will Learn
Who This Book Is For
- Fit test to legacy code retrospectively
- Install and configure popular Swift BDD frameworks
- Practice BDD with Xcode
Software practitioners, such as Swift developers and mobile app testers.
Abhishek Mishra has been developing software for over 12 years and has experience with a diverse set of programming languages and platforms. He holds a Masters degree in Computer Science from the University of London and is a freelance consultant and trainer specializing in iOS development. He is the author of Swift iOS: 24-Hour Trainer and iPhone & iPad App: 24-Hour Trainer. He was also the technical editor on Professional iOS Programming.
Chapter 1 title: Introduction to Test-Driven Development- What is Test Driven Development- Key Principles of Test Driven Development-------- Test First-------- Red - Green - Refactor-------- Remove Duplication- Architectural Patterns-------- Dependency Injection-------- Single Responsibility- Swift Mocking and Stubbing Techniques
Chapter 2 title: Writing your first set of Unit Tests.- Download and Install Xcode- Introducing the CookieMonster Project- Creating the Xcode project.- Creating the CookieModel Object- Creating the CookieBuilder Object- Displaying Results in the Xcode Console- Architectural Patterns-------- The Builder Pattern
Chapter 3 title: Introducing the MVVM pattern- Apple's Model-View-Controller Implementation- Microsoft's MV-VM Pattern.- Challenges Implementing MV-VM in iOS Applications.-------- Using Protocols to create Bindings.-------- Using RxSwift to create Bindings.
Chapter 4 title: Applying TDD techniques to the data model.- Why Test The Model- Building The Bank Account Class Using TDD Techniques- Building the Transaction Class Using TDD Techniques- Adding Support For Account Balance in The Bank Account Class- Testing a CoreData Model Class
Chapter 5 title: Testing View Controllers- Introducing the LoginScreen project- Creating a Local Stub Server- Creating the View Controller Using Test-Driven Techniques- Creating the View Model Using TDD Techniques- Creating the Model Using TDD Techniques
Chapter 6 title: Testing Collection Views- The MVVM Architecture for Collection Views- Building Model Objects- Building the Cell View Model- Building the CollectionView View Model- Building the ColllectionViewCell - Building the CollectionView
Chapter 7 title: Testing NSURLSessionIntroducing the RestaurantList AppOverview of the RESTful APICreating Model ObjectsCreating The Service ManagerMocking NSURLSession
Chapter 8 title: Testing Legacy code- The Problem of Untested Legacy Code- Adding Functionality To An Existing Legacy Class--- Sprouts--- Wrappers--- Decorators- Dealing With a Large Class--- Single Responsibility- Dependency Breaking Techniques--- Extracting Protocols--- Preserve Signatures--- Replace Concrete Method Parameters With Protocols--- Dependency Injection
Chapter 9 title: Continuious Integration- Download and Install Mac OSX Server- Configure the Xcode Build Server- Client-side XCode changes - Integrating a Bot- Deploying an Integration to a Provisioned Device.
Chapter 10 title: Introduction to BDD- What is Behaviour Driven Development- Advantages and Disadvantages of BDD- Testing Code vs Testing Behaviour- Turning Business Requirements to Testable Scenarios- Patterns and Anti-Patterns- UI vs Non-UI Acceptance Tests
Chapter 11 title: Installing Quick - Installing Quick with Cocoapods- Installing Quick with Carthage- Configuring Your Xcode Project- Using Nimble for Assertions.Chapter 12 title: Applying BDD and TDD techniques - Reviewing The Business Requirements for The Project- Defining The Features and User Stories- Writing Down the Test Scenarios- Creating the Xcode Project- Creating BDD Test Cases with Quick- Implementing the RestaurantSearch View Controller- Implementing the RestaurantList View Controller- Implementing the Service Manager- Satisfying the Acceptance Criteria.
Chapter 13 title: Testng the UI- Adding Support for UI Testing to Your Project- Key Parts of a UI Test Case- Key Classes- Assertions- UI Test Recording- Waiting For Elements