Skip to content

Instantly share code, notes, and snippets.

@technotariat
Last active December 8, 2024 21:17
Show Gist options
  • Select an option

  • Save technotariat/c643641c9f02670d87342959dad06a34 to your computer and use it in GitHub Desktop.

Select an option

Save technotariat/c643641c9f02670d87342959dad06a34 to your computer and use it in GitHub Desktop.
XCUITest with Page Object Model
import XCTest
class ExamplePOM {
let app: XCUIApplication
init(app: XCUIApplication) {
self.app = app
}
func pressTheButton() {
// perform the action
self.app.buttons["Button to Press"].tap()
// check the result of doing the action
XCTAssertTrue(app.staticTexts["Button pressed"].exists)
}
}
final class ATest: XCTestCase {
var app: XCUIApplication!
var examplePom: ExamplePOM!
override func setUpWithError() throws {
continueAfterFailure = false
app = XCUIApplication()
app.launch()
examplePom = ExamplePOM(app: app)
}
@MainActor
func testAThing() {
examplePom.pressTheButton()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment