Some days ago our team was playing around with tes...
# compose
a
Some days ago our team was playing around with tests and I found a potential problem on using
testTag
as identifiers for composables, as those use String. And as we have it harcoded all around the composables (like
Modifier.testTag("RowItem")
) and then use
"RowItem"
on tests... with possible issue when renaming one or other... I've played a bit with it and came up for possible solution on not duplicating the strings... Would these make sense on compose?
As well as it's test methods
onNodeWithId()
, etc
m
Maybe not the answer you were looking for, but just because something uses String doesn't require you to "hardcode" these values and duplicate them. You can create vals with these identifiers and use them in your code and in tests as well.
a
yea, I know that.. it was a discussion with a member of the team... but i thougth... why not use what android does for free?
I mean, keep unique value for identifiers
d
We've been using semantics and accessibility to identify items. The one item to consider is how you're using it. E.g., we use it forautomation. The down side is the framework we built has to know at a view level if it is based on semantics so we use the correct rule.