airbnb / Showkase

🔦 Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements
https://medium.com/airbnb-engineering/introducing-showkase-a-library-to-organize-discover-and-visualize-your-jetpack-compose-elements-d5c34ef01095
Apache License 2.0
2.13k stars 107 forks source link

onScreenshot method never called during instrumented tests #200

Closed davidvavra closed 2 years ago

davidvavra commented 2 years ago

Hi, I'm trying to build a sample app for article about this library & screenshot testing.

When I run ./gradlew connectedDebugAndroidTest, the onScreenshot() method is never called.

Here is the code of the sample app: https://github.com/davidvavra/showkase-screenshot-tests

I'm not sure what's wrong, it works in my work app, but not in this sample app. I have double checked both implementations, but maybe I missed something. Can you help?

vinaygaba commented 2 years ago

Hi David! I pulled your project and was able to find the root cause. You will need to add this line in your build.gradle files

kaptAndroidTest "com.airbnb.android:showkase-processor:1.0.0-beta08"

You will also need to make sure that you add this activity in your AndroidManifest. This is needed by Compose but I'll try adding it to the library and hopefully that should avoid needing the user of the library from adding it separately.

<activity
            android:name="androidx.activity.ComponentActivity" />
davidvavra commented 2 years ago

Thanks a lot! Your suggestions helped.