Should we recommend users to add keys to whole screens/pages #511
Replies: 3 comments 5 replies
-
|
In my opinion this is not ideal either, because this solution seems prone to false passes. What it the top level widget's rendered but other widgets inside have not, and "Notifications" string is not visible? My solution would be to add the key to the Text widget and make it more change resistant if ie. "Notifications" would change to "What's new". Also, I think that POM comes handy in situations like this. If you check if "Notifications" is displayed, why not check other widgets on the screen - what if coming from a specific place in the app to the screen in topic makes some widget not render properly? |
Beta Was this translation helpful? Give feedback.
-
|
I agree.
I think it comes down to:
What else can we do? |
Beta Was this translation helpful? Give feedback.
-
I don't think this option is feasible. As a developer, sometimes I can notice that my change will break UI tests and adjust accordingly (for example moving the key to a new widget). But since I am not the one writing these tests, it would be impossible for me to keep track of all UI tests and how my changes will affect them. Unit tests are cheap to run so I can immediately get feedback whether I broke something; with UI tests we do not have this luxury.
That's more realistic, since it is easy to notice a Though this is touching on a more general topic than "adding keys to whole screens": how to make tests resilient to refactors. Regarding the original question I would say keeping a key for the whole page sounds good, but as @pietraniktx has said it depends what you are actually testing. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I often see that testers need a way to simply assert "I am on this screen", but almost always they don't have a way to do this reliably.
For example, I've very recently seen this test in one of the projects.
The test is OK, but I have the problem with the last line. Even though the "Notifications" text has nothing to do with this test, it was used as a way to make sure that we've reached the home screen (on which the "Notifications" text always is). After a week, this test started failing, because the "Notifications" text was no longer on the home screen because of the development.
I think that using arbitrary widgets (and might change at any time during the development) that are present on some screen to assert that some screen is visible is a bad pattern. I see 2 solutions to this:
Below is what I'd expect the aforementioned test to look like after going the solution (2):
I'd like to recommend our users to add keys to top-level widgets (screens/pages), but before I do this, I'd like to hear you: @jBorkowska @jakubfijalkowski @mateuszwojtczak @shilangyu.
Beta Was this translation helpful? Give feedback.
All reactions