-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
Description
Issue
-
Default UITest implication is hard to manage and not readable.
-
Affecting developer to not wanting to start writing UITest or not liking UITest.
Solution
- Include a boilerplate for easy adoption of UITest.
Example of Boilerplate code
enum ViewId {
case general(General)
func callAsFunction() -> String {
switch self {
case let .general(general): return general.rawValue
}
}
}
extension ViewId {
enum General: String {
case keyboard = "general.keyboard"
case loadingSpinner = "general.loading.spinner"
}
}
// UIKit
extension UIView {
func setAccessibilityId(_ viewId: ViewId) {
accessibilityIdentifier = viewId()
}
}
// SwiftUI
extension View {
func accessibility(_ viewId: ViewId) -> some View {
accessibilityIdentifier(viewId())
}
}
protocol ScreenProtocol: AnyObject {
associatedtype Identifier: RawRepresentable where Identifier.RawValue == String
var application: XCUIApplication { get }
}
extension ScreenProtocol {
var keyboard: KeyboardScreen {
KeyboardScreen(in: application)
}
func find(
_ elementKey: KeyPath<XCUIApplication, XCUIElementQuery>,
with identifier: Identifier
) -> XCUIElement {
return application[keyPath: elementKey][identifier.rawValue]
}
}
Who Benefits?
Template users.
What next?
- Vote if we want UITest boilerplate in Template.
- Discuss on UITest pattern.
- Include new UITest pattern to iOS Template as needed.
Reactions are currently unavailable