Closed weissi closed 4 years ago
The
do { try someOperation() XCTFail("should throw") // easy to forget } catch error as SomethingError { XCTAssertEqual(.something, error as? SomethingError) } catch { XCTFail("wrong error") }
pattern is not only very long, it's also very error prone. If you forget any of the XCTFails, you might not tests what it looks like
XCTAssertThrowsError(try someOperation) { error in XCTAssertEqual(.something, error as? SomethingError) }
is much safer and shorter.
We should replace all uses of this pattern in Tests/**.
Tests/**
See also https://github.com/apple/swift-nio/pull/1430 which does the same for swift-nio.
swift-nio
see also:
The
pattern is not only very long, it's also very error prone. If you forget any of the XCTFails, you might not tests what it looks like
is much safer and shorter.
We should replace all uses of this pattern in
Tests/**
.See also https://github.com/apple/swift-nio/pull/1430 which does the same for
swift-nio
.