Skip to main content
main-content

Über dieses Buch

This short step by step guide walks you through unit testing, mocking and continuous integration and how to get these key ingredients running in your Swift projects. This book also looks at how to write your Swift apps using test driven development (TDD).
Agile practices have made major inroads in iOS development, however it’s very unusual to see something as basic as unit testing on a Swift application. Done correctly, Agile development results in a significant increase in development efficiency and a reduction in the number of defects.
Apple has released unit testing and code coverage frameworks for Swift development in XCode. Up until now getting unit testing up and running in Swift was not for the faint-hearted. Thankfully now, there is no excuse other than a lack of information on where to get started.
iOS developers are faced with their own set of problems such as tightly coupled code, fragmentation, immature testing tools all of which can be solved using existing Agile tools and techniques. After using this book, you'll learn how to make your Swift apps agile and sound.
What You Will Learn:How to write unit tests in Swift
How to write an application using Test Driven Development
Refactoring
Mocking frameworks
How to set up and configure a Continuous Integration Server
How to measure code coverage
GUI Testing

Who This Book Is For:
Swift developers and would be mobile app testers will benefit from the guidance in this book.

Inhaltsverzeichnis

Frontmatter

Chapter 1. Introduction

Swift was announced at the WWDC in 2014 and surprisingly in 2015 the code was open sourced. It can run on both OSX and Ubuntu, which is a huge departure for Apple, which has typically been a more closed system. The Swift language is a completely different animal than Objective-C.

Godfrey Nolan

Chapter 2. Swift Unit Testing

Swift's implementation of unit testing uses the XCTest library. Swift does not use OCUnit for any unit testing. XCTest is easy to set up and works within Xcode, on the command line in OSX, or on the open source Linux version of Swift.

Godfrey Nolan

Chapter 3. Third-Party Tools

You are going to need some extra third-party tools to make sure your tests are FIRST class tests.

Godfrey Nolan

Chapter 4. Mocking

One of the major goals, whether it’s on the iOS platform or not, is to isolate the code that we’re testing. When we write our tests, we want to test a specific class’s method without any of the associated interactions with other classes in the app or any external elements, such as a web service. We should be testing a single method, not its dependencies. This method should also be the only code covered by the test, with everything else mocked.

Godfrey Nolan

Chapter 5. UI Testing

iOS apps fail for a number of reasons other than simple logic errors that we typically catch with unit tests. The app may not install correctly, or there may be a problem when you move from landscape to portrait and back again. Your layout also might not work on one of the devices that you forgot to test it on. Or it might just hang if the network is down, leaving the user with no option but to close the app.

Godfrey Nolan

Chapter 6. Test Driven Development

It wouldn't be right if we didn't make an effort to show Test Driven Development (TDD) in action. So in this chapter we're going to create an app from scratch using our TDD approach. The sample app we're going to create using TDD will be for a daily horoscope. I'm not a fanatic about astrology by any means, but it's a simple app that will allow us to show our TDD techniques in action.

Godfrey Nolan

Backmatter

Weitere Informationen

Premium Partner

Neuer Inhalt

BranchenIndex Online

Die B2B-Firmensuche für Industrie und Wirtschaft: Kostenfrei in Firmenprofilen nach Lieferanten, Herstellern, Dienstleistern und Händlern recherchieren.

Whitepaper

- ANZEIGE -

Best Practices für die Mitarbeiter-Partizipation in der Produktentwicklung

Unternehmen haben das Innovationspotenzial der eigenen Mitarbeiter auch außerhalb der F&E-Abteilung erkannt. Viele Initiativen zur Partizipation scheitern in der Praxis jedoch häufig. Lesen Sie hier  - basierend auf einer qualitativ-explorativen Expertenstudie - mehr über die wesentlichen Problemfelder der mitarbeiterzentrierten Produktentwicklung und profitieren Sie von konkreten Handlungsempfehlungen aus der Praxis.
Jetzt gratis downloaden!

Bildnachweise