Issue #646
Sync the DispatchQueue
Pass DispatchQueue
and call queue.sync
to sync all async works before asserting
Use mock
Use DispatchQueueType
and in mock, call the work immediately
import Foundation
public protocol DispatchQueueType {
func async(execute work: @escaping @convention(block) () -> Void)
}
extension DispatchQueue: DispatchQueueType {
public func async(execute work: @escaping @convention(block) () -> Void) {
async(group: nil, qos: .unspecified, flags: [], execute: work)
}
}
final class MockDispatchQueue: DispatchQueueType {
func async(execute work: @escaping @convention(block) () -> Void) {
work()
}
}