I'm trying to test an API I'm writing with Structured Concurrency. I prefer to run my tests with continueAfterFailure = false
so that I may establish preconditions on my tests. At the moment my test is:
func testRssUrl() async throws {
self.continueAfterFailure = false
let xml = PodcastXml.url(url)
let feed = try await xml.feed
let rssFeed: RSSFeed? = feed.rssFeed
XCTAssertNil(rssFeed) // Included for this sample
XCTAssertNotNil(rssFeed)
validate(zebraFeed: rssFeed!)
}
My expectation of Swift Concurrency is that the try await
should hold the method, until xml.feed
resolves to a value or throws. Either of the XCTAssertNil
or XCTAssertNotNil
should fail (in the actual test, I'm not using NotNil
). As written, between the two asserts and the try, validate(zebraFeed: )
should never be called because of continueAfterFailure
.
Yet it is. The test still fails because XCTAssertNil
is failing, which is my actual expectation. Test execution should also be stopping there.
What am I missing?