Awesome
Aluminum is part of the E-sites iOS Suite.
Applying the robot pattern to your UI XCTests.
Special thanks to Rob Whitaker.
Installation
Podfile:
target 'YourUITestTarget' do
pod 'Aluminum'
end
And then
pod install
Implementation
Create your robots
import Foundation
import XCTest
import Aluminum
class WelcomeRobot: Aluminum.Robot {
lazy var startButton = app.buttons["WelcomeStartButton"]
override func requiredElements() -> [XCUIElement] {
return [ startButton ]
}
@discardableResult
func openList() -> ListRobot {
startButton()
return ListRobot(app: app)
}
}
class ListRobot: Aluminum.Robot {
lazy var cell0 = app.cells["Cell0"]
override func requiredElements() -> [XCUIElement] {
return [ cell0 ]
}
@discardableResult
func openDetail() -> DetailRobot {
cell0.tap()
return DetailRobot(app: app, parent: self)
}
}
class DetailRobot: Aluminum.Robot, Aluminum.NavigableRobot {
lazy var titleLabel = app.staticTexts["DetailTitleLabel"]
var parent: ListRobot!
required convenience init(app: XCUIApplication, parent: ListRobot) {
self.init(app: app)
self.parent = parent
}
override func requiredElements() -> [XCUIElement] {
return [ titleLabel ]
}
@discardableResult
func checkTitle() -> DetailRobot {
XCTAssertEqual(titleLabel.label, "Desired text")
}
}
Run the test
func testUI() {
let app = XCUIApplication()
WelcomeRobot(app: app)
.openList()
.openDetail()
.checkTitle()
}