Latest 1.1.2
Homepage https://github.com/e-sites/Aluminum
License MIT
Platforms ios 9.0, requires ARC
Frameworks XCTest
Authors

Aluminum

Aluminum is part of the E-sites iOS Suite.


Applying the robot pattern to your UI XCTests.
Special thanks to Rob Whitaker.

forthebadge forthebadge

Platform
CocoaPods Compatible
Carthage compatible
Travis-ci

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()
}

Latest podspec

{
    "name": "Aluminum",
    "version": "1.1.2",
    "platforms": {
        "ios": "9.0"
    },
    "summary": "Robot pattern for your XCTests",
    "authors": {
        "Bas van Kuijck": "[email protected]"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/e-sites/Aluminum",
    "source": {
        "git": "https://github.com/e-sites/Aluminum.git",
        "tag": "1.1.2"
    },
    "source_files": "Aluminum/**/*.{h,swift}",
    "requires_arc": true,
    "swift_version": "4.2",
    "frameworks": "XCTest"
}

Pin It on Pinterest

Share This