How to write Unit Test for Alamofire request function?
<p>I have a project where I'm sending .GET requests to get data from the server and for this I'm using Alamofire &amp; SwiftyJSON.</p>

<p>For example:</p>

<p>I have file "Links", "Requests" and my ViewController.</p>

<p><strong>Links.swift</strong></p>

<pre><code>var getAllData: String {
    return "\(host)api/getalldata"
}
</code></pre>

<p><strong>Requests.swift</strong></p>

<pre><code>func getAllData(_ completion:@escaping (_ json: JSON?) -&gt; Void) {
    Alamofire.request(Links.sharedInstance.getAllData).validate().responseJSON { (response) in
        do {
            let json = JSON(data: response.data!)
            completion(json)
        }
    }
}
</code></pre>

<p><strong>ViewController</strong></p>

<pre><code>Requests.sharedInstance.getAllData { (json) in
    // ...
}
</code></pre>

<p>So, how can I write my Unit Test for this case? I'm just now learning unit testing and in all books there are just local cases and no examples with network cases. Can anyone, please, describe me and help how to write Unit Tests for network requests with Alamofire and SwiftyJSON?</p>