-
Notifications
You must be signed in to change notification settings - Fork 12
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
[RFC] Add UITest ViewId and ScreenProtocol to template for easy UITest setup #397
Comments
@blyscuit We mentioned about KIF in our compass, so I think it's better to combine both KIF and the boilerplate code. |
Vote on KIF |
@suho Let me research in to that. The built-in interaction functions and speed up seems nice, but if it adds too much complexity to the setup then we could create the lib ourself. |
If we uses KIF, we can remove half of the boilerplate (XCUITest related) but we will need some KIF boilerplate. |
@blyscuit You can check this one: https://github.com/nimblehq/redplanet-ios/tree/master/RedPlanetKIFTests |
@suho Any idea why we stopped using KIF in our recent projects? |
@blyscuit We did not include UI test into our recent projects, it's more related to the Team Lead who decides to add ui tests or not 😁 |
@blyscuit I'd love the idea, the example above and your POC are good. Thanks! I voted for both RFCs. Some suggestions that I think might be cleaner. // Bring this to View+Accessibility.swift
extension UIView {
func setAccessibilityId(_ viewId: ViewId) {
accessibilityIdentifier = viewId()
}
} We're going to define extension ViewId {
enum General
enum Home
enum Login
...
} And having separate extension files like: // ViewId+General.swift
extension ViewId.General: String {
case keyboard = "general.keyboard"
case loadingSpinner = "general.loading.spinner"
}
// ViewId+Home.swift
extension ViewId.Home: String {
case profileButton = "home.profile.button"
case loadingSpinner = "home.loading.spinner"
}
// ViewId+Login.swift
extension ViewId.Login: String {
case loginButton = "login.login.button"
case emailField = "home.email.field"
}
|
@vnntsu Thank you. I will refactor them, these suggestion should be the norm 🙇 . |
@vnntsu I ran in to this issue with adding case to extending enum Best course is to extend
I also tried other approaches but personally the current way is the best when:
I'm open to more discussion to the approach. |
Hi @blyscuit, I've checked your KIF POC. It's great 👏 In addition, we may need to add some extra verifications as improvements for the tests. We also need to check the content of the UI in case we can. For example, we may want to check that the login button is enabled after the form was filled with valid data. Or we can verify the number on the label has the right format and so on. So I recommended adding let surveyImage = self.tester().waitForView(withAccessibilityIdentifier: ViewId.home(.surveyImage)())
expect(surveyImage).notTo(beNil())
let numberLabel = self.tester().waitForView(withAccessibilityIdentifier: ViewId.home(.numberLabel)()) as? UILabel
expect(numberLabel?.text) == "1,000"
let startButton = self.tester().waitForView(withAccessibilityIdentifier: ViewId.home(.startButton)()) as? UIButton
expect(startButton?.isEnabled) == true I also want to shorten the function |
@blyscuit Add these functions can make writing more cool 🙏 extension KIFUITestActor {
func waitForView(withViewID viewID: ViewID) {
waitForView(withAccessibilityIdentifier: viewID())
}
func waitForTappableView(withViewID viewID: ViewID) {
waitForTappableView(withAccessibilityIdentifier: viewID())
}
func enterText(_ text: String, intoViewWithViewID viewID: ViewID) {
enterText(text, intoViewWithAccessibilityIdentifier: viewID())
}
func tapView(withViewID viewID: ViewID) {
tapView(withAccessibilityIdentifier: viewID())
}
}
// Writing test
self.tester().waitForView(withViewID: .splash(.background)) |
@markgravity I think we should use |
@blyscuit From my recent experiment, repeating type |
@markgravity I agree it is a pain. Maybe we can add this extension.
|
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
Example of Boilerplate code
Who Benefits?
Template users.
What next?
The text was updated successfully, but these errors were encountered: