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

introduce Preview screenshot testing with Showkase and Roborazzi #3

Merged
merged 1 commit into from
Aug 28, 2023

Conversation

morux2
Copy link
Owner

@morux2 morux2 commented Aug 28, 2023

No description provided.

@morux2 morux2 merged commit 20e1cda into master Aug 28, 2023
@takahirom
Copy link

@morux2
Looks great! May I incorporate this information into Roborazzi's documentation or an issue to clarify how to use Roborazzi with Showkase?

@morux2
Copy link
Owner Author

morux2 commented Aug 30, 2023

@takahirom
Thank you for your message .I have referred to your PR of DroidKaigi.
Of course! I'd be happy to assist with the documentation work.


ご連絡ありがとうございます!DroidKaigiのPRを参考に実装させていただきました!
もちろん参照いただいて大丈夫です。もしよろしければドキュメンテーションのお手伝いができたら嬉しいです。

@@ -2,6 +2,7 @@ plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'io.github.takahirom.roborazzi'
id 'com.google.devtools.ksp'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the dependency to your module's build.gradle file. If you have a multi-module setup, add this dependency to all the modules with UI elements that should be displayed inside the Showkase browser.
Showkase supports both ksp and kapt. By default, it uses kapt as we only recently added ksp support.

https://github.com/airbnb/Showkase#installation

import com.airbnb.android.showkase.annotation.ShowkaseRootModule

@ShowkaseRoot
class ShowkaseScreenshotModule : ShowkaseRootModule
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define an implementation of the ShowkaseRootModule interface in your root module.

https://github.com/airbnb/Showkase#installation

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required to call Showkase.getMetadata()

@Test
fun previewScreenshot() {
val filePath =
DEFAULT_ROBORAZZI_OUTPUT_DIR_PATH + "/" + showkaseBrowserComponent.group + "_" + showkaseBrowserComponent.componentName + ".png"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

スクリーンショット 2023-09-25 12 25 19

you can retrieve the preview name or group name and apply it as the filename.


companion object {

@ParameterizedRobolectricTestRunner.Parameters
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the syntax for parameterized tests in Robolectric.

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

Successfully merging this pull request may close these issues.

2 participants