nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.
MIT License
5.56k stars 671 forks source link

Find by AccessibilityIdentifier #77

Open gmcadosch opened 2 years ago

gmcadosch commented 2 years ago

There's a find(viewWithId:) function, but as I already set the accessibilityIdentifier property on all views for UI testing, I needed a new find function. I implemented this as a shortcut:

extension InspectableView { func find(_ id: String) throws -> InspectableView { try find { try $0.accessibilityIdentifier() == id } } }

Would be nice to see something like this integrated into the standard package as probably everyone doing UI testing already has those identifiers set.

nalexn commented 2 years ago

Hey, feel free to open a PR for that, great idea!

nalexn commented 2 years ago

I'd only picked a more verbose name for func find(_ id: String) to not be confused with other modifiers, including find(viewWithId:).

Maybe find(viewWithAccessibilityId:) ?

gmcadosch commented 2 years ago

Yes, thought the same, but it‘s a bit long, though. But in regard to the other find versions it‘s probably the right name.

Am 25.01.2022 um 18:28 schrieb Alexey Naumov @.***>:

 I'd only picked a more verbose name for func find(_ id: String) to not be confused with other modifiers, including find(viewWithId:).

Maybe find(viewWithAccessibilityId:) ?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.