SenTestingKit: How Does it Even?

Have you ever wondered what used to happen when you hit ⌘U to run your unit tests in Xcode 4.6 and prior? Here's a step-by-step sequence of events detailing how tests are loaded and run using SenTestingKit.

As I explain in Probing SenTestingKit, XCTest (née SenTestingKit) has changed surprisingly little since it was first adopted by Apple in 2005. Although what follows is based on the 2005 source code to SenTestingKit, I assume Xcode 7 and XCTest still operate very similarly. I'll test that assumption in future blog posts.

1. Xcode invokes a command-line tool called otest to run your tests.

$3+ patron-only content

Details on what the otest executable is, what arguments it takes, and how it loads the test bundle.

I am a patronBecome a patron

2. SenTestProbe Determines How it Was Launched

$3+ patron-only content

An explanation of the SenTestProbe class.

I am a patronBecome a patron

3. SenTestProbe Initializes Observers

$3+ patron-only content

An explanation of how SenTestProbe intiializes observers that print out test progress and results, as well as an examination of a design flaw in SenTestingKit.

I am a patronBecome a patron

3. SenTestProbe Initializes a Test Suite

$3+ patron-only content

An explanation of how SenTestProbe initializes a SenTestSuite composed of test cases.

I am a patronBecome a patron

4. The Test Suite is Run

$3+ patron-only content

An explanation of how the test suite executes each of the test methods defined by the user.

I am a patronBecome a patron


Well, there you have it–everything that happens in SenTestingKit after hitting ⌘U in Xcode 4.6.

In an upcoming post, I'll explore how this series of events has changed in subsequent versions of XCTest. For example, the version of XCTest packaged with Xcode includes XCTestObservationCenter, which can (in theory) register more than one test observer.