Skip to content

Cannot save screenshots on Windows, works on MACos #346

Description

@GustavoEliseu

Preface

I am integrating screenshot testing in my Jetpack Compose application. I'm using api level 34 and i'm facing some issues that only affect my Windows computer, on the same project running on my MacOS works flawless. Already using the non-SDK interfaces https://github.com/pedrovgs/Shot#using-shot-on-api-28

Dependencies

Shot => 6.0.0
Jetpack Compose => 1.5.3
Android Gradle Plugin => 8.1.2

Systems

Failure on this system:

System Windows 11
Android Studio Giraffe 2022.3.1
ProjectPath

C:\Users\gusta\AndroidStudioProjects\Mypokedex

Working on this system:

System MacOS Ventura 13.6
Android Studio Giraffe 2022.3.1
ProjectPath

/Users/Amaral/Documents/GitHub/MyPokedexApp

Configuration

plugins {
    alias(libs.plugins.com.android.library)
    alias(libs.plugins.org.jetbrains.kotlin.android)
    id("kotlin-kapt")
    id("shot")
}

android {
    namespace = "com.gustavoeliseu.pokedexlist"
    compileSdk = 34

    shot {
        applicationId = "ge.pokedexlist"
    }
    defaultConfig {
        testApplicationId = "ge.pokedexlist"
        minSdk = 26
        testInstrumentationRunner = "com.karumi.shot.ShotTestRunner"
    }

    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.4.7"
    }

Sample

 @get:Rule
    var composeRule = createComposeRule()

    @Test
    fun verify_pokemon_ditto_card_snapshot() {
        composeRule.setContent {
            PokemonCardTest(
                id = 132,
                name = "Ditto",
                pokemonColorId = 6
            )
        }
        compareScreenshot(composeRule)
    }

Device

Tested it with 2 emulators with Pixel 6 API 349 and API 26 via Android Studio. Also tested with a Xiamoi poco f3 (M2012K11AG). Got the same result with all of them.

Command

./gradlew executeScreenshotTests -Precord

Output

> Task :app:debugDownloadScreenshots
??  Pulling screenshots from your connected devices!
Shot ADB warning: We could not pull screenshots from folder: /storage/emulated/0/Download/screenshots/ge.pokedexlist/screenshots-default/
Shot ADB warning: We could not pull screenshots from folder: /storage/emulated/0/Download/screenshots/ge.pokedexlist/screenshots-compose-default/
Shot ADB warning: rm: /storage/emulated/0/Download/screenshots/ge.pokedexlist/screenshots-default/: No such file or directory
Shot ADB warning: rm: /storage/emulated/0/Download/screenshots/ge.pokedexlist/screenshots-compose-default/: No such file or directory

> Task :app:debugExecuteScreenshotTests
?  Saving screenshots.
? We couldn't find any screenshot. Did you configure Shot properly and added your tests to your project? https://github.com/pedrovgs/Shot/#getting-started

Behaviour

The screenshots are being generated and are deleted when the command ends, but only on windows it fails when trying to copy them to the project folder. Maybe it's related to the saving path on windows.

I never worked with Scala but if you give me a direction to where look at, i can run some tests on both machines to find the cause of this problem. I can also create a dualboot with linux to test on all platforms.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions