How to Test Swift async/await Code With XCTest
Because async/await is a feature at the Swift language level, to test an
asyncfunction we can use the same approach we’d use to consume that code in production: call it withawait.[…]
To appreciate how neater this is than the approach we used before the introduction of
async await, let me show you the same test but for achopVegetablesversion using callbacks andResult.[…]
Unfortunately the
XCTAssertThrowsErrorand the other assertion APIs don’t support concurrency yet, sodo catchis the only option to test the error path ofasynccode.