Bam
11/04/2024, 5:09 PM.testTag(...)
, but did a little search to see if any new tools, best practices, approaches, etc, had been introduced. To my surprise, and also reluctant agreement, I see advice against the use of .testTag(...)
being the go-to solution for testing Compose.
Strong argument against: https://proandroiddev.com/stop-using-test-tags-in-the-jetpack-compose-production-code-b98e2679221f
Milder argument against: https://callmeryan.medium.com/efficient-testing-or-code-pollution-the-role-of-testtag-in-jetpack-compose-testing-4892ee73e966
I also want as clean production code as possible, and if I can find a way to not introduce testTag everywhere in my code, I would love that.
Want to get people thoughts and see what everyone is doing for Compose instrumentation testing.jw
11/04/2024, 5:35 PMBam
11/04/2024, 6:17 PM.testTag(...)
as a last resort, favouring instead:
⢠Actual text in elements, potentially leveraging String resources, which would allow me to do testing on multiple languages. š¤
⢠ContentDescriptions
, which is essentially how ScreenReaders work for accessibility. This will also force me to set useful ContentDescriptions for things. Will need to investigate best practices to not go overboard.
⢠Semantics
using the states provided by the ViewModels (where it's reasonable to do so).
⢠And good old tree navigation. "Look for the button with X, under the field with Y, above the text with Z".
I've never encountered the Role
description for a Composable, but might also be something for me to look into.
Feel free to throw any other suggestions at me if anyone has any. šš¼jw
11/04/2024, 6:21 PMDavid
11/04/2024, 10:09 PMchristian.steffensen
11/05/2024, 5:47 AMjw
11/05/2024, 5:49 AMjw
11/05/2024, 5:50 AMjw
11/05/2024, 5:51 AMchristian.steffensen
11/05/2024, 6:47 AM