Skip to content

Instantly share code, notes, and snippets.

@danielCarlosCE
Created August 20, 2017 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielCarlosCE/7c8319d8c70bee61e7ff94ddb0694422 to your computer and use it in GitHub Desktop.
Save danielCarlosCE/7c8319d8c70bee61e7ff94ddb0694422 to your computer and use it in GitHub Desktop.
private extension XCTestCase {
func XCTAssertThrows<T, E>(_ expression: @autoclosure () throws -> T, specificError: E) where E: Error, E: Equatable {
XCTAssertThrowsError(try expression()) { error in
XCTAssertEqual(error as? E, specificError)
}
}
}
//use case
class TestCase: XCTestCase {
func testValidateWithInvalidEmailDoesThrowInvalidEmailError () {
XCTAssertThrows(try validate(), specificError: FormError.invalidEmail)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment