Helpers

  • Allows to verify if error was thrown, and if it is of given type.

    Declaration

    Swift

    public func XCTAssertThrowsError<T, E: Error>(
        _ expression: @autoclosure () throws -> T,
        of error: E.Type,
        _ message: @autoclosure () -> String = "",
        file: StaticString = #file,
        line: UInt = #line
    )

    Parameters

    expression

    Expression

    error

    Expected error type

    message

    Optional message

    file

    File (optional)

    line

    Line (optional)

  • Allows to verify if error was throws, and if its exactly the one expected.

    Declaration

    Swift

    public func XCTAssertThrowsError<T, E>(
        _ expression: @autoclosure () throws -> T,
        error: E, _ message: @autoclosure () -> String = "",
        file: StaticString = #file,
        line: UInt = #line
    ) where E: Error, E: Equatable

    Parameters

    expression

    Expression

    error

    Expected error conforming to Equatable, Error

    message

    Optional message

    file

    File (optional)

    line

    Line (optional)

  • You can use this class if there is need to define custom assertion handler. You can use its static handler closure to alter default behaviour.

    If it is nil, the default assert method would be used.

    See more

    Declaration

    Swift

    public final class MockyAssertion