Extensions on
XCTestCase
Methods
values(for:dropFirst:expectedNumber:whenExecutingClosure:)
func values<T, P: Publisher>(for publisher: P,
dropFirst: Int = 1,
expectedNumber: Int = 1,
whenExecutingClosure closure: () -> Void) -> [T]
where P.Output == T, P.Failure == Never
Helper method for testing the values of Publisher
in response to other code being executed.
Parameters
Name | Type | Description |
---|---|---|
publisher | P |
A non-failable publisher |
dropFirst | Int |
Value to pass to |
expectedNumber | Int |
The number of |
closure | () -> Void |
The method will execute this closure and then wait for |
Returns
The collected values from the publisher
.
reject(_:dropFirst:whenExecutingClosure:)
func reject<T, P: Publisher>(_ publisher: P, dropFirst: Int = 1, whenExecutingClosure closure: () -> Void)
where P.Output == T, P.Failure == Never
Helper method for verifying that Publisher
does not send any .next
events when executing the given closure.
Parameters
Name | Type | Description |
---|---|---|
publisher | P |
A non-failable publisher. |
dropFirst | Int |
Value to pass to |
closure | () -> Void |
The method will execute this closure and then wait to verify that |
waitUntilFalse(_:)
func waitUntilFalse<P: Publisher>(_ publisher: P)
where P.Output == Bool, P.Failure == Never
Waits for the given Bool publisher to send a value of false before proceeding.
timeDelayedFuture(result:on:after:)
func timeDelayedFuture<O, E, S>(result: Result<O, E>,
on scheduler: S,
after delay: S.SchedulerTimeType.Stride) -> Future<O, E>
where E: Error, S: Scheduler
Helper method to return a future that completes after a certain amount of time
Parameters
Name | Type | Description |
---|---|---|
result | Result<O, E> |
the |
scheduler | S |
scheduler on which to return the |
delay | S.SchedulerTimeType.Stride |
time interval after which the future should complete |
Returns
a Future
that completes in a set amount of time on a given scheduler.
timeDelayedFuture(result:after:)
func timeDelayedFuture<O, E>(result: Result<O, E>, after delay: TimeInterval) -> Future<O, E>
where E: Error
Helper method to return a future that completes after a certain amount of time
Parameters
Name | Type | Description |
---|---|---|
result | Result<O, E> |
the |
delay | TimeInterval |
time interval (in seconds) after which the future should complete |
Returns
a Future
that completes in a set amount of time on a DispatchQueue.global()
.