CustomDump Documentation

Function XCTAssert​NoDifference(_:​_:​_:​file:​line:​)

@available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *)
public func XCTAssertNoDifference<T>(
  _ expression1: @autoclosure () throws -> T,
  _ expression2: @autoclosure () throws -> T,
  _ message: @autoclosure () -> String = "",
  file: StaticString = #filePath,
  line: UInt = #line
) where T: Equatable  

Asserts that two values have no difference.

Similar to XCTAssertEqual, but that function uses either TextOutputStreamable, CustomStringConvertible or CustomDebugStringConvertible in order to display a failure message:

XCTAssertEqual(user1, user2)
XCTAssertEqual failed: ("User(id: 42, name: "Blob")") is not equal to ("User(id: 42, name: "Blob, Esq.")")

XCTAssertNoDifference uses the output of diff(_:_:format:) to display a failure message, which helps highlight the differences between the given values:

XCTAssertNoDifference(user1, user2)
XCTAssertNoDifference failed: …

    User(
      id: 42,
  -   name: "Blob"
  +   name: "Blob, Esq."
    )

(First: -, Second: +)

Parameters

expression1 @autoclosure () throws -> T

An expression of type T, where T is Equatable.

expression2 @autoclosure () throws -> T

A second expression of type T, where T is Equatable.

message @autoclosure () -> String

An optional description of a failure.

file Static​String

The file where the failure occurs. The default is the filename of the test case where you call this function.

line UInt

The line number where the failure occurs. The default is the line number where you call this function.