View StoryRobot.swift
This file contains 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
final class StoryRobot: Robot { | |
private lazy var stackView = app.otherElements["StoryView.stackView"] | |
private lazy var multimediaImage = stackView.images["StoryView.multimediaImageView"] | |
private lazy var titleLabel = stackView.staticTexts["StoryView.titleLabel"] | |
private lazy var abstractLabel = stackView.staticTexts["StoryView.abstractLabel"] | |
private lazy var bylineLabel = stackView.staticTexts["StoryView.bylineLabel"] | |
@discardableResult | |
func checkStoryImage() -> Self { |
View StoryUITest.swift
This file contains 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
final class StoryUITest: XCTestCase { | |
private lazy var app = XCUIApplication() | |
func testStory() { | |
StoryRobot(app) | |
.start() | |
.checkTitle(contains: "U.S. - Politics") | |
.checkStoryImage() | |
.checkStoryTitle(contains: "A Trump Endorsement Can Decide a Race. Here’s How to Get One.") |
View Predicate.swift
This file contains 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
enum Predicate { | |
case contains(String), doesNotContain(String) | |
case exists, doesNotExist | |
case isHittable, isNotHittable | |
var format: String { | |
switch self { | |
case .contains(let label): | |
return "label == '\(label)'" | |
case .doesNotContain(let label): |
View Robot.swift
This file contains 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 Robot { | |
private static let defaultTimeout: Double = 30 | |
var app: XCUIApplication | |
lazy var navigationBar = app.navigationBars.firstMatch | |
lazy var navigationBarButton = navigationBar.buttons.firstMatch | |
lazy var navigationBarTitle = navigationBar.otherElements.firstMatch |
View UglyUITest.swift
This file contains 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 uglyUITest() { | |
... | |
app.launch() | |
let title = app.navigationBars.firstMatch.otherElements.firstMatch | |
XCTAssert(title.isHittable) | |
XCTAssertEqual(title.label, "U.S. - Politics") | |
let stackView = app.otherElements["StoryView.stackView"] | |
let multimediaImage = stackView.images["StoryView.multimediaImageView"] | |
XCTAssert(multimediaImage.isHittable) | |
let titleLabel = stackView.staticTexts["StoryView.titleLabel"] |
View PrettyUITest.swift
This file contains 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 prettyUITest() { | |
... | |
StoryRobot(app) | |
.start() | |
.checkTitle(contains: "U.S. - Politics") | |
.checkStoryImage() | |
.checkStoryTitle(contains: "A Trump Endorsement Can Decide a Race. Here’s How to Get One.") | |
.checkStoryAbstract(contains: "The president’s grip on G.O.P. primary voters is as strong as it has been since he seized the party’s nomination.") | |
.checkStoryByline(contains: "By JONATHAN MARTIN and MAGGIE HABERMAN") | |
.takeScreenshot(named: "Story") |
View SomethingViewController.swift
This file contains 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
final class SomethingViewController: UIViewController, Accessible { | |
@IBOutlet private weak var titleLabel: UILabel! | |
@IBOutlet private weak var descriptionLabel: UILabel! | |
@IBOutlet private weak var doneButton: UIButton! | |
override func viewDidLoad() { | |
generateAccessibilityIdentifiers() | |
} | |
} |
View Accessible.swift
This file contains 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
protocol Accessible { | |
func generateAccessibilityIdentifiers() | |
} | |
extension Accessible { | |
func generateAccessibilityIdentifiers() { | |
#if DEBUG | |
let mirror = Mirror(reflecting: self) |
View SomethingViewController.swift
This file contains 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
final class SomethingViewController: UIViewController { | |
@IBOutlet private weak var titleLabel: UILabel! | |
@IBOutlet private weak var descriptionLabel: UILabel! | |
@IBOutlet private weak var doneButton: UIButton! | |
override func viewDidLoad() { | |
titleLabel.accessibilityIdentifier = "SomethingViewController.titleLabel" | |
descriptionLabel.accessibilityIdentifier = "SomethingViewController.descriptionLabel" | |
doneButton.accessibilityIdentifier = "SomethingViewController.doneButton" |
View Request+Url.swift
This file contains 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
extension Request { | |
var absoluteUrl: String { | |
guard let query = parameters.query else { | |
return url | |
} | |
return "\(url)?\(query)" | |
} | |
} |
NewerOlder