Function

XCTAssertNotNil(_:_:file:line:)

Asserts that an expression is not nil.

Declaration

func XCTAssertNotNil(_ expression: @autoclosure () throws -> Any?, _ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line)

Parameters

expression

An expression of type Any? to compare against nil.

message

An optional description of the failure.

file

The file in which failure occurred. Defaults to the file name of the test case in which this function was called.

line

The line number on which failure occurred. Defaults to the line number on which this function was called.

Discussion

Generates a failure when expression == nil.

See Also

Testing if a Condition is Non-nil

func XCTUnwrap<T>(() -> T?, () -> String, file: StaticString, line: UInt) -> T

Asserts that an expression is not nil and returns the unwrapped value.