Publisher

@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public extension Publisher
  • Assert that a publisher fails with a specified Error type

    Declaration

    Swift

    func assertError<E: Error>(
      type: E.Type,
      message: String? = nil,
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable

    Parameters

    type

    The expected error type

    message

    The optional message on failure

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert than a publisher fails with the expected error

    Declaration

    Swift

    func assertError<E: Error & Equatable>(
      equals error: E,
      message: String? = nil,
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable

    Parameters

    error

    The expected error

    message

    The optional message on failure

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert that a publisher fails

    Declaration

    Swift

    func assertFailure(
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable

    Parameters

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert that published value(s) are equal to an expected value

    Declaration

    Swift

    func assert<T: Equatable>(
      equals value: T,
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable where Output == T

    Parameters

    value

    The expected value

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert that published values are greater than the specified value

    Declaration

    Swift

    func assert<T: Comparable>(
      greaterThan value: T,
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable where Output == T

    Parameters

    value

    The value that published output should be greater than

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert that published values are greater than or equal to the specified value

    Declaration

    Swift

    func assert<T: Comparable>(
      greaterThanOrEqualTo value: T,
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable where Output == T

    Parameters

    value

    The value that published output should be greater than or equal to

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert that published values are less than the specified value

    Declaration

    Swift

    func assert<T: Comparable>(
      lessThan value: T,
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable where Output == T

    Parameters

    value

    The value that published output should be less than

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert that published values are less than or equal to the specified value

    Declaration

    Swift

    func assert<T: Comparable>(
      lessThanOrEqualTo value: T,
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable where Output == T

    Parameters

    value

    The value that published output should be less than or equal to

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert published values are nil

    Declaration

    Swift

    func assertNil<T>(
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable where Output == Optional<T>

    Parameters

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert published values are not nil

    Declaration

    Swift

    func assertNotNil<T>(
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line
    ) -> AnyCancellable where Output == Optional<T>

    Parameters

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

  • Assert that an published values meet a given predicate

    Declaration

    Swift

    func assert(
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line,
      _ predicate: @escaping (Output) -> Bool
    ) -> AnyCancellable

    Parameters

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

    predicate

    The predicate evaluated for each published value

  • Assert that an expression is true

    Declaration

    Swift

    func assertTrue(
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line,
      _ predicate: @escaping (Output) -> Bool
    ) -> AnyCancellable

    Parameters

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

    predicate

    The predicate evaluated for each published value

  • Assert that an expression is false

    Declaration

    Swift

    func assertFalse(
      expectation: XCTestExpectation? = nil,
      file: StaticString = #file,
      line: UInt = #line,
      _ predicate: @escaping (Output) -> Bool
    ) -> AnyCancellable

    Parameters

    expectation

    An optional expectation; if testing asynchrounous calls, this will need to be passed otherwise you will receive false positives.

    predicate

    The predicate evaluated for each published value