-
Diagnose unreliable code with test repetitions
Test repetitions can help you debug even the most unreliable code. Discover how you can use the maximum repetitions, until failure, and retry on failure testing modes within test plans, Xcode, and xcodebuild to track down bugs and crashers and make your app more stable for everyone.
To get the most out of this session, we recommend being familiar with XCTest and managing tests through test plans. For more information, check out “Testing in Xcode” from WWDC19.Ressources
Vidéos connexes
WWDC22
WWDC21
-
Rechercher dans cette vidéo…
-
-
2:39 - testFlavors
func testFlavors() { var truck: IceCreamTruck? let flavorsExpectation = XCTestExpectation(description: "Get ice cream truck's flavors") truckDepot.iceCreamTruck { newTruck in truck = newTruck newTruck.prepareFlavors { error in XCTAssertNil(error) } flavorsExpectation.fulfill() } wait(for: [flavorsExpectation], timeout: 5) XCTAssertEqual(truck?.flavors, 33) } -
6:31 - testFlavors: add async throws to method header
func testFlavors() async throws { var truck: IceCreamTruck? let flavorsExpectation = XCTestExpectation(description: "Get ice cream truck's flavors") truckDepot.iceCreamTruck { newTruck in truck = newTruck newTruck.prepareFlavors { error in XCTAssertNil(error) } flavorsExpectation.fulfill() } wait(for: [flavorsExpectation], timeout: 5) XCTAssertEqual(truck?.flavors, 33) } -
6:32 - testFlavors: use the async version of the ice cream truck
func testFlavors() async throws { let truck = await truckDepot.iceCreamTruck() truck = newTruck newTruck.prepareFlavors { error in XCTAssertNil(error) } flavorsExpectation.fulfill() } wait(for: [flavorsExpectation], timeout: 5) XCTAssertEqual(truck?.flavors, 33) } -
6:33 - testFlavors: use the async version of prepareFlavors
func testFlavors() async throws { let truck = await truckDepot.iceCreamTruck() try await truck.prepareFlavors() XCTAssertEqual(truck?.flavors, 33) } -
6:50 - testFlavors: the truck is no longer optional
func testFlavors() async throws { let truck = await truckDepot.iceCreamTruck() try await truck.prepareFlavors() XCTAssertEqual(truck.flavors, 33) }
-