Skip to content

Instantly share code, notes, and snippets.

@tieleman
Created February 26, 2020 12:01
Show Gist options
  • Save tieleman/ee2f9f1c049ad651a305830c2b69c3a6 to your computer and use it in GitHub Desktop.
Save tieleman/ee2f9f1c049ad651a305830c2b69c3a6 to your computer and use it in GitHub Desktop.
SimpleGreeterUITests v2
import XCTest
class SimpleGreeterUITests: XCTestCase {
override func setUp() {
continueAfterFailure = false
}
func testInitialViewState() {
let app = XCUIApplication()
app.launch()
let textField = app.textFields.element
let enterNameLabel = app.staticTexts["enterNameLabel"]
let greeterLabel = app.staticTexts["greetingTextLabel"]
XCTAssert(enterNameLabel.exists)
XCTAssertEqual(enterNameLabel.label, "Please enter your name below")
XCTAssert(greeterLabel.exists)
XCTAssert(greeterLabel.label.isEmpty)
XCTAssert(textField.exists)
XCTAssertEqual(textField.placeholderValue, "Your name")
}
func testGreeter() {
let app = XCUIApplication()
app.launch()
let textLabel = app.staticTexts["greetingTextLabel"]
let textField = app.textFields.element
textField.tap()
textField.typeText("J")
textField.typeText("o")
textField.typeText("n")
textField.typeText("y")
XCTAssertEqual(textLabel.label, "Nice to meet you, Jony.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment