Skip to content
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

Testing on different devices #281

Open
kataRebuy opened this issue Mar 22, 2024 · 5 comments
Open

Testing on different devices #281

kataRebuy opened this issue Mar 22, 2024 · 5 comments

Comments

@kataRebuy
Copy link

Currently, if I want to test the same stuff on 3 different devices I have to write the tests 3 times. It would be nice to get a feature where you can run the same test with different device configs.
Like this:

@Config(qualifiers = listOf(Pixel5, SmallPhone))

Of course then including the device config name in the screenshots file name to be able to distinguish between them.

@takahirom
Copy link
Owner

It's a reasonable approach. For now, we can refer to the implementation used by Now In Android for multi-device testing. In a nutshell, we can use RuntimeEnvironment.setQualifiers() as follows: RuntimeEnvironment.setQualifiers("w${width}dp-h${height}dp-${dpi}dpi").

https://github.com/android/nowinandroid/blob/bd89507f10f4f569bcb0af157135351ed2c4e5ce/core/screenshot-testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt#L52

@takahirom
Copy link
Owner

We can integrate the multi-device feature into Roborazzi if we find a suitable API. Currently, however, I don't have one.
You can utilize the roboOutputName() function to retrieve the default name of the Roborazzi image, which allows you to append the device name to it.

@kataRebuy
Copy link
Author

That is a nice solution. It would be convenient if it were part of the library.

@takahirom
Copy link
Owner

We already have that function, but I didn't mention it in the document. So, now is the time to include it.
https://github.com/search?q=repo%3Atakahirom%2Froborazzi%20roboOutputName&type=code

@sergio-sastre
Copy link

@kataRebuy In case it helps: did write about that (and more) here 👇
https://sergiosastre.hashnode.dev/efficient-testing-with-robolectric-roborazzi-across-many-ui-states-devices-and-configurations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants