Holy Moly, I just found out about `XCTAssertThrows`! I'm gonna refactor so many unit tests.

#swiftdev #iosdev

@weston If you need to test for an error being thrown in an async context, various folks contributed to figuring it out on Stack Overflow: https://stackoverflow.com/questions/58633811/how-to-assert-an-error-is-thrown-async-when-testing/76649847#76649847
How to assert an error is thrown async when testing?

We can test thrown errors with XCTAssertThrowsError. Async things can be tested with expectation. I have some method which dispatch work to a background thread and can at some point throw an error....

Stack Overflow
And a code snippet for the `assertThrowsAsyncError` function that can be used with #XCTest: #SwiftDev
https://gitlab.com/-/snippets/2567566
Asynchronous test assertion helper ($2567566) · Snippets · GitLab

GitLab.com

GitLab