unit and acceptance testing, automation, productivity

Posts tagged "swift"

Using Swift protocols to abstract third party dependencies and improve testability

Third party code can be hard to test, but you can use Swift's protocols to abstract its details and improve testability

way to enhance local reasoning and facilitate testability

Nimble: when to use waitUntil or toEventually

The Nimble matchers framework provides two ways assert expectations on asynchronous code, this post explores when to use one or the other.


Porting Ruby's unless operator into Swift via a function.

XCTest closure based expectations

Testing async code is not simple, but XCTest provides us with all the required tool. This post shows how to wait for an expectation to be fulfilled based on a Swift closure.

How to use dependency injection for classes in Swift

In Swift it is possible to pass a reference to a type itself, not just to an instance of it. This post shows how to use this capability to test legacy code.

Implicitly vs Force Unwrapping Swift Optionals

A look at what implicitly unwrapping and force unwrap a Swift Optional mean, and how they differ from each other.

Why Implicitly Unwrapping Swift Optionals Is Dangerous

A look at what implicitly unwrapping an Optional value means and why it should be avoided.

Swift Either enum

This post introduces the Either type and shows a practical application of it in Swift, injecting extra cells in a table view.

Writing your own Swift "if let"

An exercise to understand Swift's optional type: reimplementing the if let functionality

What is an optional value in Swift

This post looks into one of Swift's most powerful feature: optionals

How to make Swift methods unavailable

A quick post showing how to use the Swift availability attribute to mark objects and functions as unavailable.

Functional Core Reactive Shell

This is a blogpost version of the content of my talk "Functional Core, Reactive Shell"

NSDateFormatter format for JSON dates

How to configure NSDateFormatter to work with JSON API dates.

Async Testing with Quick and Nimble

A look at how to write tests for async code when using the Quick and Nimble Swift frameworks. This post is part of the Practical Testing in Swift series.

Testing Delegates in Swift with XCTest

In this second post of the Practical Testing in Swift we a look at strategies to test how objects call their delegate methods or set property on them.

Testing callbacks in Swift with XCTest

Prevent Unit Tests from Loading AppDelegate in Swift

How to prevent the unit test target from loading the AppDelegate and have faster tests execution.

Fixing Bugs Driven By Tests in Swift

Unit and acceptance test are powerful tools that can be used to identify and fix bugs. Let's see how using a bugged Swift app as an example.

When to use map, flatMap, or for loops in Swift

Swift allows us to natively iterate over arrays using map. Map could be used to replace every for loop in your code, but that's not a great idea. Map and for have different purposes and should be used appropriately

Swift Optionals, Functional Programming, and You

This is the post version of a talk I've been given in the past months. In this post we will demystify functional programming terms like monad and functor, and see how those concepts can be brought back to the every day Swift development, in particular how they can help to deal with optionals in a leaner way.

Enhancing XCTest test cases with Nimble matchers

Nimble is a matchers framework built for Swift that provides powerful and versatile expectations. Writing test within the standard XCTest harness but using Nimble assertions is easier and productive, and a good combination of tools to introduce testing and TDD to colleagues and teams in a frictionless way.

Explicit Dependencies, Swift Edition

A look at how to write classes and structs that expose their dependencies as initialization arguments in Swift.

Swift array of characters from String

How to get an array of single characters String from a multiple characters String. From foobar to [f, o, o, b, a, r].

Packaging an ipa with Swift files from the terminal

If you are having problems with xcodebuild failing to export your apps with either Swift or Watch Kit support here's the solution, with a handy custom script.

Swift Functors, Applicatives, and Monads in Pictures

In this port to Swift of the great of Haskell's "Functors, Applicatives, And Monads In Pictures" we are going to look at these functional programming concepts aided by some very helpful pictures.