Skip to main content
Apress

Test-Driven Development in Swift

Compile Better Code with XCTest and TDD

  • Book
  • © 2021

Overview

  • Test any kind of software, simple or complicated, pure logic or interfacing, with third-party dependencies
  • Gain helpful guidance from compiler errors as from failing tests
  • Solve problems incrementally by writing only as much code as necessary

This is a preview of subscription content, log in via an institution to check access.

Access this book

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

eBook USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

') var buybox = document.querySelector("[data-id=id_"+ timestamp +"]").parentNode var buyboxMaxSingleColumnWidth = 480 // springerPlus roll out 10% starts here var springerPlusGroup = setLocalStorageSpringerPlus(); var rollOutSpringerPlus = springerPlusGroup === "B" function setLocalStorageSpringerPlus() { var selectUserKey = "springerPlusRollOut"; var springerPlusGroup = "X"; if (!window.localStorage) return springerPlusGroup; try { var selectUserValue = window.localStorage.getItem(selectUserKey) springerPlusGroup = selectUserValue || randomDistributionSpringerPlus(selectUserKey) } catch (err) { console.log(err) } return springerPlusGroup; } function randomDistributionSpringerPlus(selectUserKey) { var randomGroup = Math.random() < 0.7 ? "A" : "B" window.localStorage.setItem(selectUserKey, randomGroup) return randomGroup } if (rollOutSpringerPlus) { revealSpringerPlus(); } function revealSpringerPlus() { if(buybox) { document.querySelectorAll(".c-springer-plus").forEach(function(node) { node.style.display = "block" }) } } //springerPlus ends here ;[].slice.call(buybox.querySelectorAll(".buying-option")).forEach(initCollapsibles) function initCollapsibles(buyingOption, index) { var toggle = buyingOption.querySelector(".buying-option-price") buyingOption.classList.remove("expanded") var form = buyingOption.querySelector(".buying-option-form") var priceInfo = buyingOption.querySelector(".price-info") if (toggle && form && priceInfo) { toggle.setAttribute("role", "button") toggle.setAttribute("tabindex", "0") toggle.addEventListener("click", function (event) { var expandedBuyingOptions = buybox.querySelectorAll(".buying-option.expanded") var buyboxWidth = buybox.offsetWidth ;[].slice.call(expandedBuyingOptions).forEach(function(option) { if (buyboxWidth <= buyboxMaxSingleColumnWidth && option != buyingOption) { hideBuyingOption(option) } }) var expanded = toggle.getAttribute("aria-expanded") === "true" || false toggle.setAttribute("aria-expanded", !expanded) form.hidden = expanded if (!expanded) { buyingOption.classList.add("expanded") } else { buyingOption.classList.remove("expanded") } priceInfo.hidden = expanded }, false) } } function hideBuyingOption(buyingOption) { var toggle = buyingOption.querySelector(".buying-option-price") var form = buyingOption.querySelector(".buying-option-form") var priceInfo = buyingOption.querySelector(".price-info") toggle.setAttribute("aria-expanded", false) form.hidden = true buyingOption.classList.remove("expanded") priceInfo.hidden = true } function initKeyControls() { document.addEventListener("keydown", function (event) { if (document.activeElement.classList.contains("buying-option-price") && (event.code === "Space" || event.code === "Enter")) { if (document.activeElement) { event.preventDefault() document.activeElement.click() } } }, false) } function initialStateOpen() { var buyboxWidth = buybox.offsetWidth var narrowBuyboxArea = buyboxWidth <= buyboxMaxSingleColumnWidth var allOptionsInitiallyCollapsed = buybox.className.indexOf("all-options-initially-collapsed") > -1 ;[].slice.call(buybox.querySelectorAll(".buying-option")).forEach(function (option, index) { var toggle = option.querySelector(".buying-option-price") var form = option.querySelector(".buying-option-form") var priceInfo = option.querySelector(".price-info") if (allOptionsInitiallyCollapsed || narrowBuyboxArea && index > 0) { toggle.setAttribute("aria-expanded", "false") form.hidden = "hidden" priceInfo.hidden = "hidden" } else { toggle.click() } }) } initialStateOpen() if (window.buyboxInitialised) return window.buyboxInitialised = true initKeyControls() })()

Other ways to access

Licence this eBook for your library

Institutional subscriptions

About this book

Leverage Swift to practice effective and efficient test-driven development (TDD) methodology. Software testing and TDD are evergreen programming concepts—yet Swift developers haven't widely adopted them. What's needed is a clear roadmap to learn and adopt TDD in the Swift world. Over the past years, Apple has invested in XCTest and Xcode's testing infrastructure, making testing a new top priority in their ecosystem. Open-source libraries such as Quick and Nimble have also reached maturity. The tools are there. This book will show you how to wield them. 

TDD has much more to offer than catching bugs. With this book, you’ll learn a philosophy for building software. TDD enables engineers to solve problems incrementally, writing only as much code as necessary. By decomposing big problems into small steps, you can move along at a fast pace, always making visible progress. 

Participate in the test-driven development journey by building a real iOS application and incorporating new concepts through each chapter. The book's concepts will emerge as you figure out ways to use tests to drive the solutions to the problems of each chapter. Through the TDD of a single application, you’ll be introduced to all the staples and advanced concepts of the craft, understand the trade offs each technique offers, and review an iterative process of software development. 

Test-Driven Development in Swift provides the path for a highly efficient way to make amazing apps.

What You'll Learn

  • Write tests that are easy to maintain
  • Look after an ever-growing test suite
  • Build a testing vocabulary that can be applied outside the Swift world
  • See how Swift programming enhances the TDD flow seen in dynamic languages 
  • Discover how compiler errors can provide the same helpful guidance as failing tests do

Who This Book Is For

Mid-level developers keen to write higher quality code and improve their workflows. Also, developers that have already been writing tests but feel they are not getting the most out of them. 







Similar content being viewed by others

Keywords

Table of contents (16 chapters)

Authors and Affiliations

  • Mount Martha, Australia

    Gio Lodi

About the author

Gio Lodi spent the past decade writing tests. He began with full-stack web development before moving into iOS programming and, more recently, into mobile infrastructure engineering. Ruby on Rails introduced him to the TDD world, and he fell in love with the fast-paced feedback loop. Any big problem could be decomposed in smaller and smaller parts until it got to an achievable size. Due to the lack of tools he first encountered moving into the Apple ecosystem, Gio researched and experimented with testing strategies and tools document in an ongoing project that catalogued on his blog and in talks and workshops at various industry conferences. 

Bibliographic Information

  • Book Title: Test-Driven Development in Swift

  • Book Subtitle: Compile Better Code with XCTest and TDD

  • Authors: Gio Lodi

  • DOI: https://doi.org/10.1007/978-1-4842-7002-8

  • Publisher: Apress Berkeley, CA

  • eBook Packages: Professional and Applied Computing, Apress Access Books, Professional and Applied Computing (R0)

  • Copyright Information: Gio Lodi 2021

  • Softcover ISBN: 978-1-4842-7001-1Published: 02 July 2021

  • eBook ISBN: 978-1-4842-7002-8Published: 01 July 2021

  • Edition Number: 1

  • Number of Pages: XIX, 288

  • Number of Illustrations: 18 b/w illustrations

  • Topics: Apple and iOS

Publish with us

Navigation