Your First iOS App: Coding in Swift

Jul 28 2026 · Swift 6.3, iOS 26, Xcode 26

Lesson 02: Intro to Unit Testing

Intro to Unit Testing

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Like it or not, almost every program you’ll ever write will have bugs. It happens even to the best programmers. It’s just human nature - we’re imperfect!

Add Unit Testing

Alright so we want to add some unit tests to Bullseye here. And the way we do this is this is your project navigator. Remember a long time ago I said there were other navigators?

Add Tests

And then what we’re going to do here is, here’s the set up with error. Which as we discussed is where you do your initial setup for all of your tests.

class BullseyeTests: XCTestCase {
  var game: Game!
  override func setUpWithError() throws {
    game = Game()
  }
import XCTest
@testable import Bullseye
override func tearDownWithError() throws {
  game = nil
}
func testExample() throws {
  XCTAssertEqual(game.points(sliderValue: 50), 999)
}

Run the tests

Now that we have our test, there’s three ways that we can run this.

See forum comments
Cinema mode Download course materials from Github
Previous: The Swift Standard Library Next: Intro to Test-Driven Development