Xcode 7: Profiling Unit Tests in Instruments

January 26th, 2016

Filed under: Instruments, Xcode | Be the first to 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 […]

Getting OCMock to Work with XCTest

October 7th, 2013

Filed under: Xcode | 1 comment

XCTest does not currently have built-in support for mock objects so you’ll need an external framework like OCMock for mock object support. OCMock versions 2.2 and later work with XCTest. I had only one problem getting OCMock to work with XCTest. When I ran my tests, I would get a warning saying that the test […]

Xcode 5: Unit Testing Changes

September 30th, 2013

Filed under: Xcode | 6 comments

One of the biggest areas of change in Xcode 5 involves unit testing. This post details those changes. Test Navigator Xcode 5 adds a test navigator to the available navigators on the left side of the project window. You can see an example of the test navigator in the following screenshot: The test navigator has […]