Xcode 10: Running Tests in Random Order

November 6th, 2018

Filed under: Xcode | Be the first to comment!

In Xcode 10 you can tell Xcode to run your tests in random order. Open the scheme editor for your project and select the Test step. Click the Options button next to the test target to open a popover. Select the Randomize execution order checkbox to run your tests in random order.

Getting Started with Unit Testing in Swift 4

June 13th, 2018

Filed under: Cocoa, iOS Development, Mac Development, Xcode | Be the first to comment!

One of the most read articles on this blog is An Introduction to Swift Unit Testing. The article is almost four years old and uses Swift 1. Because of that I have decided to build upon that article here, updating the code to Swift 4 and adding an example project to unit test. The Project […]

Xcode 7: Profiling Unit Tests in Instruments

January 26th, 2016

Filed under: Instruments, Xcode | 1 comment

I learned about this tip from an Apple engineer on Apple’s developer forums and felt like sharing it here. Xcode 7 lets you profile unit tests in Instruments, using the following steps: Open the test navigator. Right-click on a test or a group of tests in the test navigator. Choose Profile “testMethod”, where testMethod is […]

@testable Import

July 6th, 2015

Filed under: Xcode | Be the first to comment!

A new feature added in Xcode 7 to simplify unit testing is the @testable import statement. Instead of making your application classes members of the unit testing target, which is what you had to do to unit test Swift code in Xcode 6, add the following statement to your unit testing classes: @testable import MyApp […]

An Introduction to Swift Unit Testing

July 17th, 2014

Filed under: Cocoa, Xcode | 4 comments

This article shows you how to get started unit testing Swift code in Xcode with XCTest. If you’ve written Objective-C unit tests using XCTest or OCUnit, you should be able to smoothly transition to Swift after reading the article. But Objective-C unit testing experience isn’t required to read this article. Because Xcode 6 is currently […]