โ˜‘๏ธUnit/UI Test

If you choose to add tests to your project, Xcode will create two additional targets: one for unit tests and one for UI tests.

structure for a test case:

  • Arrange: arrange the "system under test" (SUT) and the "inputs".

  • Act: act on the SUT to get the "output".

  • Assert: assert the "output" matches the "expected result".

func testEmptyMenuReturnsEmptySections() {
    
    // โญ๏ธ Arrange: (arrange inputs)
    let menu = [MenuItem]() 
    
    // โญ๏ธ Act: (generate output)
    let sections = menu.groupedByCategory()
    
    // โญ๏ธ Assert: (assert match)
    XCTAssertTrue(sections.isEmpty)
}

Last updated