Created
August 20, 2017 14:03
-
-
Save danielCarlosCE/7c8319d8c70bee61e7ff94ddb0694422 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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