-
Notifications
You must be signed in to change notification settings - Fork 3
Description
MetovaTestKit already contains two assertions for dealing with Objective-C level exceptions, as documented here.
Should we include assertions for dealing with Swift level errors? I understand that both XCTAssertThrowsError and XCTAssertNoThrow exist, and I generally prefer to not rewrite Apple code, however I have two issues with both of these methods.
First, the signature for the Xcode Test functions is arguably confusing or misleading. We generally prefer closure arguments to be last so we can leverage Swift's nice trailing closure syntax, as we did with Exception Testing Functions. The Xcode Test default functions have the closure to be tested as the first argument. This is done presumably because all of the following arguments are optional (and only used in very rare occasion... they're for people doing things like what we're doing with MTK) and to be consistent with every other function in the Xcode Test suite, which is fair enough.
Second, and arguably more importantly, the Xcode Test functions do not allow you to have much information about the error that was thrown (other than what was printed), nor does it allow you to make further assertions about the thrown error. The first problem is relatively minor, but the second problem can potentially get in the way of writing a complete test suite, particularly in the case where you want to assert that an error was thrown. You certainly want to be sure the error was of the type you were expecting and it contained all the information you expected to, otherwise you might have false positive results. If we were to implement these assertions in MTK, we would return any thrown error we encountered, just as we do with Objective-C exceptions we catch in the exception testing methods.
However, I believe everything else in MTK is purely supplemental functions. These two additions would mark the first replacements for existing XCT functionality.