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
set -e | |
set +u | |
# Avoid recursively calling this script. | |
if [[ $SF_MASTER_SCRIPT_RUNNING ]] | |
then | |
exit 0 | |
fi | |
set -u | |
export SF_MASTER_SCRIPT_RUNNING=1 |
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
set -e | |
set +u | |
# Avoid recursively calling this script. | |
if [[ $SF_MASTER_SCRIPT_RUNNING ]] | |
then | |
exit 0 | |
fi | |
set -u | |
export SF_MASTER_SCRIPT_RUNNING=1 |
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
override func setUp() { | |
continueAfterFailure = false | |
dynamicStubs.setUp() | |
app.launchEnvironment = ["BASEURL" : "http://localhost:8080", "isUITest":"true"] | |
continueAfterFailure = false | |
super.setUp() | |
} | |
override func tearDown() { | |
super.tearDown() |
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
func testMoviesList() { | |
dynamicStubs.setupStub(url: "/Movies", filename: "listOfMovies", method: .GET) | |
app.launch() | |
} |
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
[ | |
{ | |
"name": "Avengers: Infinity War", | |
"rating": "8.5", | |
"desc": "The Avengers and their allies must be willing to sacrifice all in an attempt to defeat the powerful Thanos before his blitz of devastation and ruin puts an end to the universe.", | |
}, | |
{ | |
"name": "Bohemian Rhapsody", | |
"rating": "8.4", | |
"desc": "A chronicle of the years leading up to Queen's legendary appearance at the Live Aid (1985) concert.", |
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
func testShowingMovieNameAndImageName() { | |
dynamicStubs.setupStub(url: "/Movies", filename: "listOfMovies", method: .GET) | |
app.launch() | |
let tablesQuery = app.tables | |
// Assert on first movie | |
XCTAssertTrue(tablesQuery.cells.staticTexts["Avengers: Infinity War"].exists, "Failure: did not show the first movie name.") | |
XCTAssertTrue(tablesQuery.cells.staticTexts["8.5"].exists, "Failure: did not show the first movie ratting.") |
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
func testShowingMovieNameAndImageName() { | |
let networkLayer = NetworkLayerMock(mockedData: [["name":"Avengers: Infinity War", "ratting": "8.5"], ["name":"Bohemian Rhapsody", "ratting": "8.4"]]) | |
let moviesListModel = MoviesListModel(networkLayer: networkLayer) | |
let moviesListPresenter = MoviesListPresenter(moviesListModel: moviesListModel) | |
let viewControllerMock = ViewControllerMock() | |
moviesListPresenter.delegate = viewControllerMock | |
moviesListPresenter.fetchMovies() | |
XCTAssertTrue(viewControllerMock.didFetchMovies, "Success in fetching movies") | |
XCTAssertTrue(moviesListPresenter.movieName(index:0) == "Avengers: Infinity War", "First movie name is not as expected") |
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
open func executeGETRequest(api:String, completionBlock:@escaping (Data?) -> Void) { | |
let environment = ProcessInfo.processInfo.environment | |
var baseUrl:String = "" | |
if let _ = environment["isUITest"] { | |
// Running in a UI test | |
baseUrl = ProcessInfo.processInfo.environment["BASEURL"]! | |
} else { | |
baseUrl = "https://api.example.com" | |
} |
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
class NetworkLayerMock: Network { | |
private let mockedData: [[String:String]] | |
init(mockedData:[[String:String]]) { | |
self.mockedData = mockedData | |
} | |
override func executeGETRequest(api:String, completionBlock:@escaping (Data?) -> Void) { | |
let data = toJSONString(mockedData: self.mockedData) |
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
func testFetchingMoviesFromNetworkLayer() { | |
let networkLayer = NetworkLayerMock(mockedData: [["name":"name1", "ratting": "12"], ["name":"name2", "ratting": "123"]]) | |
let movieslistModel = MoviesListModel(networkLayer: networkLayer) | |
let moviesListModelDelegateMock = MoviesListModelDelegateMock() | |
movieslistModel.delegate = moviesListModelDelegateMock | |
movieslistModel.fetchMovies() | |
XCTAssertTrue(moviesListModelDelegateMock.movies.count == 2, "Failed to return the expected count of movies") | |
let firstMovie = moviesListModelDelegateMock.movies[0] |
OlderNewer