-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add convenience finding methods and XCTestCase to test by accessibility #168
Conversation
Hi @nalexn, would you be interested in having these added to the project. If yes, I will go ahead and also add documentation |
Hey @FrauR Thank you for submitting the PR! The new methods you've added:
You can certainly publish your helper separately as a snippet and we can leave a reference to it from the readme or other place in the project. Let me know what you think, and possibly update the PR as needed. Thanks! |
I think the additions here, if they are not preventing the use of Quick/Nimble, would be welcome to many people including our team. This code is not hitting production (it's part of the unit test target) so even if the library has a few extra functions that cater only to XCTest users, it should be fine. Looking forward to using them! |
@nalexn sorry, that I didn't get back earlier. I totally agree with you and also think the |
@nalexn can we merge this? |
Hey, sure, I'll merge this for the next version. I just wanted to wrap up work on a couple more tickets before making a release. No ETA unfortunately due to lack of free time 😔 |
I've used this code below myself. Not necessary better. Agree that accessibility identifiers are very nice to use in the tests. extension InspectableView {
func find<T>(_ viewType: T.Type,
accessibilityIdentifier: String) throws -> InspectableView<T> where T: KnownViewType {
return try find(viewType) { view in
(try? view.accessibilityIdentifier()) == accessibilityIdentifier
}
}
func findButton(_ accessibilityIdentifier: String) throws -> InspectableView<ViewType.Button> {
try find(ViewType.Button.self, accessibilityIdentifier: accessibilityIdentifier)
}
} |
Why these changes
We would like to remove boiler plate code and encourage developers to use internal architecture independent
find(..)
methods that don't rely on internal implementation logic (such as the specific view types and even knowledge about the view tree).Types of changes
What types of changes does your code introduce to View Inspector?
Put an x in the boxes that apply
Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.