0Pricing
Swift Academy · Lesson

XCTAssert Family and Throwing Assertions

Using XCTAssertEqual, XCTAssertThrowsError and XCTUnwrap safely.

XCTAssert and XCTAssertTrue

XCTAssert and XCTAssertTrue fail if the condition is false.

XCTAssert(user.isLoggedIn)
XCTAssertTrue(cart.isEmpty, "Cart should be empty after clear()")

XCTAssertFalse

XCTAssertFalse fails if the condition is true.

XCTAssertFalse(session.isExpired, "Fresh session should not be expired")

All lessons in this course

  1. XCTestCase Setup, Teardown and Test Methods
  2. XCTAssert Family and Throwing Assertions
  3. Protocol-Based Mocking and Dependency Injection
  4. Async Tests and Performance Measurement
← Back to Swift Academy