This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 09:37:30.652 xcodebuild[30138:9324129] Beginning test session XYZUITests-A4F643B9-4E10-47CD-B0AB-A99724E96BAB at 2018-05-11 09:37:30.650 with Xcode 9E145 on target <DVTiPhoneSimulator: 0x7fd5f30a3b80> { | |
| SimDevice: iPhone 8 (85133256-457F-4F65-BCE2-B720B287B717, iOS 11.3, Booted) | |
| } (11.3 (15E217)) | |
| 09:37:30.653 xcodebuild[30138:9324129] /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild | |
| -workspace | |
| ./XYZ.xcworkspace | |
| -scheme | |
| Smoke Tests | |
| -destination | |
| platform=iOS Simulator,id=85133256-457F-4F65-BCE2-B720B287B717 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let httpDispatcher = HTTPDispatcher() | |
| let anyDispatcher = AnyDispatcher(httpDispatcher) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let taskReal = GetMoviesTask(dispatcher: AnyDispatcher(HTTPDispatcher())) | |
| let taskTest = GetMoviesTask(dispatcher: AnyDispatcher(TestHTTPDispatcher())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct GetMoviesTask { | |
| let dispatcher: AnyDispatcher<URLRequest, Data> | |
| func load(success: ([Movie]) -> Void, failure: (Error) -> Void) { | |
| let request = URLRequest(url: URL(string: “www.mydomain.com/movies")!) | |
| dispatcher.execute(request: request, success: { (data) in | |
| let movies = // (…) | |
| success(movies) | |
| }, failure: { error in | |
| // (…) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let anyDispatcher = AnyDispatcher<URLSession, Data> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct AnyDispatcher<R, O>: Dispatcher { | |
| private let _execute: (R, (O) -> Void, (Error) -> Void) -> Void | |
| init<D: Dispatcher>(_ dispatcher: D) where R == D.Request, O == D.Output { | |
| _execute = dispatcher.execute | |
| } | |
| func execute(request: R, success: (O) -> Void, failure: (Error) -> Void) { | |
| _execute(request, success, failure) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let dispatcher: Dispatcher<URLRequest, Data> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct GetMoviesTask { | |
| let dispatcher: Dispatcher | |
| func load(success: ([Movie]) -> Void, failure: (Error) -> Void) { | |
| let request = URLRequest(url: URL(string: “www.mydomain.com/movies")!) | |
| dispatcher.execute(request: request, success: { data in | |
| // (…) | |
| }, failure: { error in | |
| // (…) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let task1 = GetMoviesTask(dispatcher: HTTPDispatcher()) | |
| let task2 = GetMoviesTask(dispatcher: TestHTTPDispatcher()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct HTTPDispatcher: Dispatcher { | |
| func execute(request: URLRequest, success: (Data) -> Void, failure: (Error) -> Void) { | |
| // executes HTTP requests using URLSession | |
| // … | |
| } | |
| } | |
| struct TestHTTPDispatcher: Dispatcher { | |
| func execute(request: URLRequest, success: (Data) -> Void, failure: (Error) -> Void) { | |
| // to be used for unit tests, returns mocked data |
NewerOlder