         waitForExpectations()
     }
 }
+
+/// Assert that the two given states are equal.
+private func assertState(_ actual: StepRunnerState, _ expected: StepRunnerState, file: StaticString = #file, line: UInt = #line) {
+    XCTAssertTrue(actual == expected, "state should be \(expected) but was \(actual)", file: file, line: line)
+}

        var stateChangeCounter = 0
        stepRunner.state.afterChange.add { change in
            switch stateChangeCounter {
            case 0:
                XCTAssertTrue(change.newValue == .inProgress(index: 0), "state should be in progress(0)")
            case 1:
                XCTAssertTrue(change.newValue == .inProgress(index: 1), "state should be in progress(1)")
            case 2:
                XCTAssertTrue(change.newValue == .success, "state should be success, was \(change.newValue)")
                exp.fulfill()
            default:
                break

        stepRunner.state.afterChange.add { change in
            switch stateChangeCounter {
            case 0:
                assertState(change.newValue, StepRunnerState.inProgress(index: 0))
            case 1:
                assertState(change.newValue, StepRunnerState.inProgress(index: 1))
            case 2:
                assertState(change.newValue, StepRunnerState.success)
            default:
                break
            }
