Skip to content

Instantly share code, notes, and snippets.

@rbrovko
rbrovko / UnitTestingSceneDelegateGist.md
Created June 1, 2026 16:05 — forked from HiddenJester/UnitTestingSceneDelegateGist.md
Mocking SceneDelegate for Unit Tests on iOS 13

Replacing the SceneDelegate When Running Unit Tests

Overview

I've been working through the exercises in the excellent iOS Unit Testing by Example book by Jon Reid, which I highly recommend. However, the book is in beta at the moment and there are some curveballs thrown by iOS 13 that aren't handled in the text yet. Specifically, when I hit the section about using a testing AppDelegate class I thought "This is very good. But what about the SceneDelegate?"

In Chapter 4 the recommendation is to remove the @UIApplicationMain decoration and make a manual top-level call to UIApplicationMain. To wit:

import UIKit
@rbrovko
rbrovko / Display.swift
Created January 24, 2020 15:48 — forked from hfossli/Display.swift
Display mode
import UIKit
public enum DisplayType {
case unknown
case iphone4
case iphone5
case iphone6
case iphone6plus
static let iphone7 = iphone6
static let iphone7plus = iphone6plus
@rbrovko
rbrovko / xcode-swift-vers
Created December 27, 2019 13:57 — forked from yamaya/xcode-swift-vers
Xcode swift version record
# Xcode 6.2 (6C131e)
Swift version 1.1 (swift-600.0.57.4)
Target: x86_64-apple-darwin14.1.0
# Xcode 6.3 (6D570)
Apple Swift version 1.2 (swiftlang-602.0.49.3 clang-clang-602.0.49)
Target: x86_64-apple-darwin14.1.0
# Xcode 6.3.1 (6D1002)
Apple Swift version 1.2 (swiftlang-602.0.49.6 clang-602.0.49)
@rbrovko
rbrovko / NoteTests.swift
Created August 9, 2019 06:11
testNote_whenImmutableNoteCopy_rateConditions
import XCTest
@testable import Notes
class NoteTests: XCTestCase {
private let uid = "123"
private let title = "title"
private let content = "text"
private let importance = Note.Importance.normal
private var sut: Note!
@rbrovko
rbrovko / NoteTests.swift
Created August 9, 2019 06:08
testNote_whenImmutableNote_rateConditions
import XCTest
@testable import Notes
class NoteTests: XCTestCase {
private let uid = "123"
private let title = "title"
private let content = "text"
private let importance = Note.Importance.normal
private var sut: Note!
@rbrovko
rbrovko / NoteTests.swift
Created August 9, 2019 06:05
testNote_whenMutableNoteCopy_rateConditions
import XCTest
@testable import Notes
class NoteTests: XCTestCase {
private let uid = "123"
private let title = "title"
private let content = "text"
private let importance = Note.Importance.normal
private var sut: Note!
@rbrovko
rbrovko / NoteTests.swift
Created August 9, 2019 06:02
testNote_whenMutableNote_rateConditions
import XCTest
@testable import Notes
class NoteTests: XCTestCase {
private let uid = "123"
private let title = "title"
private let content = "text"
private let importance = Note.Importance.normal
private var sut: Note!
@rbrovko
rbrovko / FileNotebookTests.swift
Last active July 1, 2019 16:58
iOS Unit tests for task#3 (Test target - NoteTests.swift) or Playground
//
// FileNotebookTests.swift
// NoteTests
//
// Created by Roman Brovko on 6/19/19.
// Copyright © 2019 Roman Brovko. All rights reserved.
//
import XCTest
@testable import Note
@rbrovko
rbrovko / NoteExtensionsTests.swift
Last active June 30, 2019 16:35
iOS Unit tests for task#2 (Test target - NoteTests.swift) or Playground
//
// NoteExtensionsTests.swift
// NoteTests
//
// Created by Roman Brovko on 6/18/19.
// Copyright © 2019 Roman Brovko. All rights reserved.
//
import XCTest
@testable import Note
@rbrovko
rbrovko / NoteTests.swift
Created June 19, 2019 17:44
iOS Unit tests for task#1 (Test target - NoteTests.swift) or Playground
//
// NoteTests.swift
// NoteTests
//
// Created by Roman Brovko on 6/17/19.
// Copyright © 2019 Roman Brovko. All rights reserved.
//
import XCTest
@testable import Note