Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Load from Storyboard Example iOS
import XCTest
import Hamcrest
import FutureKit
@testable import MyExampleApp
class ExampleViewControllerTest: XCTestCase {
var fakeExampleService: FakeExampleService!
override func setUp() {
super.setUp()
fakeExampleService = FakeExampleService()
}
func testServiceCallInExampleViewController() {
let stubbedResponse = MyExampleAppResponse(name: "Johnny Appleseed", favoriteFruit: "apples")
fakeExampleService.stubbedResponse = stubbedResponse
let controller = ExampleViewController.loadFromStoryboard(fakeExampleService: fakeExampleService)
assertThat(controller.view, present())
controller.searchBar.text = "Appleseed"
controller.didTapButtonToCallService(NSObject())
assertThat(fakeExampleService.lastRequest, presentAnd(equalTo("Appleseed")))
assertThat(controller.nameField.text, presentAnd(equalTo("Johnny Appleseed")))
assertThat(controller.favoriteFruitField.text, presentAnd(equalTo("apples")))
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment