Shot is an Android project you can use to write screenshot for your apps in a simple and friendly way

Overview

Karumi logoShot Build, lint, and test

Shot is an Android project you can use to write screenshot for your apps in a simple and friendly way.

What is this?

Shot is a Gradle plugin and a core android library thought to run screenshot tests for Android. This project provides a handy interface named ScreenshotTest and a ready to use ShotTestRunner you can use in order to write tests like these:

class GreetingScreenshotTest : ScreenshotTest {

    // If you are using regular Android views

    @Test
    fun theActivityIsShownProperly() {
        val mainActivity = startMainActivity();

        compareScreenshot(activity);
    }

    // If you are using Jetpack Compose

    @Test
    fun rendersGreetingMessageForTheSpecifiedPerson() {
        composeRule.setContent { Greeting(greeting) }

        compareScreenshot(composeRule)
    }
}

Since Shot 5.0.0 we provide screenshot testing support for Jetpack Compose. If you are testing your components using Shot we strongly recommend you to configure your emulator using the gpu mode swiftshader_indirect. This will help you to avoid rendering issues when verifying your screenshots from any CI environment.

smallVerificationReport1 smallVerificationReport2

Record your screenshots executing ./gradlew executeScreenshotTests -Precord

recording

And verify your tests executing ./gradlew executeScreenshotTests

verifying

If Shot finds any error in your tests execution the Gradle plugin will show a report as follows:

errorReport

You can find the complete Facebook SDK documentation here.

Getting started

Setup the Gradle plugin:

Modify your root build.gradle file:

  buildscript {
    // ...
    dependencies {
      // ...
      classpath 'com.karumi:shot:'
    }
  }

Apply the plugin from any of the modules configured in your project. In a simple Android app your app/build.gradle file:

apply plugin: 'shot'

You will also have to configure the instrumentation test runner in your module build.gradle file as follows:

android {
    // ...
    defaultConfig {
        // ...
        testInstrumentationRunner "com.karumi.shot.ShotTestRunner"
    }
    // ...

We created this test runner for you extending from the Android one.

This plugin sets up a few convenience commands you can list executing ./gradlew tasks and reviewing the Shot associated tasks:

shotTasksHelp

If you are using flavors the available Shot gradle tasks will be configured based on your flavors and build types configuration. You can find all the available shot tasks by executing ./gradlew tasks. For example, if your app has two flavors: green and blue the list of available Shot tasks will be:

executeScreenshotTests - Checks the user interface screenshot tests. If you execute this task using -Precord param the screenshot will be regenerated.
blueDebugDownloadScreenshots - Retrieves the screenshots stored into the Android device where the tests were executed for the build BlueDebug
blueDebugExecuteScreenshotTests - Records the user interface tests screenshots. If you execute this task using -Precord param the screenshot will be regenerated for the build BlueDebug
blueDebugRemoveScreenshotsBefore - Removes the screenshots recorded before the tests execution from the Android device where the tests were executed for the build BlueDebug
blueDebugRemoveScreenshotsAfter - Removes the screenshots recorded after the tests execution from the Android device where the tests were executed for the build BlueDebug
greenDebugDownloadScreenshots - Retrieves the screenshots stored into the Android device where the tests were executed for the build GreenDebug
greenDebugExecuteScreenshotTests - Records the user interface tests screenshots. If you execute this task using -Precord param the screenshot will be regenerated for the build GreenDebug
greenDebugRemoveScreenshotsBefore - Removes the screenshots recorded before the tests execution from the Android device where the tests were executed for the build GreenDebug
greenDebugRemoveScreenshotsAfter - Removes the screenshots recorded after the tests execution from the Android device where the tests were executed for the build GreenDebug

You can specify a directory suffix where screenshot & report will be saved ({FLAVOR}/{BUILD_TYPE}/{DIRECTORY_SUFFIX}) :
./gradlew executeScreenshotTests -PdirectorySuffix=Api26

If for some reason you are running your tests on a different machine and you want to skip the instrumentation tests execution and just compare the sources remember you can use the following shot configuration:

  shot {
    runInstrumentation = false
  }

Create this AndroidManifest.xml file inside your androidTest folder.

">
xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package=".test"
    android:sharedUserId=".uid">

manifest>

You'll have to add the same android:sharedUserId=".uid" configuration to your app/AndroidManfiest.xml file in order to let the testing APK write into the SDCard.. If you don't do this, you can end up facing a weird error with this message while running your tests:

java.lang.RuntimeException: Failed to create the directory /sdcard/screenshots/com.example.snapshottesting.test/screenshots-default for screenshots. Is your sdcard directory read-only?

If you want to use Shot to test your Android libraries code, you will have to configure the testApplicationId parameter as follows

" } // ...">
android {
    // ...
    defaultConfig {
        // ...
        testApplicationId ""
    }
    // ...

If you are using AGP 7.X in your Android library you may need to configure the applicationId as part of the Shot extension configuration as follows:

shot {
  applicationId = "com.myapp"
}

AGP introduced a bug in 7.0.1-alpha4 we are not able to fix without this workaround for now. In the future, once AGP fixes the bug, we will remove this extension property.

Be careful and do not use the same id you are using for any other of the installed apps.

Now you are ready to use the ScreenshotTest interface from your tests:

class MyActivityTest: ScreenshotTest {
    @Test
    fun theActivityIsShownProperly() {
            val mainActivity = startMainActivity();
           /*
             * Take the actual screenshot. At the end of this call, the screenshot
             * is stored on the device and the gradle plugin takes care of
             * pulling it and displaying it to you in nice ways.
             */
            compareScreenshot(activity);
    }
}

Since Shot 5.0.0, if you are using Jetpack Compose your tests will look like this:

class GreetingScreenshotTest : ScreenshotTest {

    @Test
    fun rendersGreetingMessageForTheSpecifiedPerson() {
        composeRule.setContent { Greeting(greeting) }

        compareScreenshot(composeRule)
    }

This interface is full of useful methods you can use to take your screenshots with your activities, dialogs fragments, view holders or even custom views

You can find a complete example in this repository under the folder named shot-consumer or review this kata.***

Now you are ready to record and verify your screenshot tests!

Using shot on API 28+

If you want to use Shot on devices running API >= 28, you will have to enable access to non-SDK interfaces.
Execute the following commands:

For Android 9 (API level 28)

adb shell settings put global hidden_api_policy_pre_p_apps 1
adb shell settings put global hidden_api_policy_p_apps 1

For Android 10 (API level 29) or higher

adb shell settings put global hidden_api_policy 1

Recording tests

You can record your screenshot tests executing this command:

./gradlew <Flavor>>ExecuteScreenshotTests -Precord

or

./gradlew executeScreenshotTests -Precord

This will execute all your integration tests and it will pull all the generated screenshots into your repository so you can easily add them to the version control system.

Executing tests

Once you have a bunch of screenshot tests recorded you can easily verify if the behaviour of your app is the correct one executing this command:

./gradlew <Flavor>>ExecuteScreenshotTests

or

./gradlew executeScreenshotTests

After executing your screenshot tests using the Gradle task ExecuteScreenshotTests a report with all your screenshots will be generated.

ScreenshotTest interface

ScreenshotTest interface has been designed to simplify the usage of the library. These are the features you can use:

  • Take a screenshot of any activity by using compareScreenshot(activity). Activity height, width, background color and screenshot name are configurable.
  • Take a screenshot of any fragment by using compareScreenshot(fragment). Fragment height, width and screenshot name are configurable.
  • Take a screenshot of any dialog by using compareScreenshot(dialog). Dialog height, width and screenshot name are configurable.
  • Take a screenshot of any view by using compareScreenshot(view). View height, width and screenshot name are configurable.
  • Take a screenshot of any view holder by using compareScreenshot(holder). View holder height, width and screenshot name are configurable.
  • Take a screenshot of any Jetpack Component compareScreenshot(composeTestRule). The screenshot name is configurable.
  • Take a screenshot of any SemanticInteractionNode compareScreenshot(node). The screenshot name is configurable.

Before taking the screenshot, Shot performs some tasks in order to stabilize the screenshot. You can find the detail about the tasks performed in ScreenshotTest#disableFlakyComponentsAndWaitForIdle:

  • Invokes disableFlakyComponentsAndWaitForIdle method you can override if you want to add any custom task before taking the screenshot.
  • Hides every EditText cursor.
  • Hides every ScrollView and HorizontalScrollView scrollbars.
  • Hides all the ignored views. You can specify the views you want to ignore by overriding viewToIgnore.
  • Wait for animations to finish and also waits until Espresso considers the UI thread is idle. This is really interesting if you are using Espresso in your tests.

You can find examples of the usage of this interface and every feature mentioned inside the examples named shot-consumer and shot-consumer-flavors.

In case you need to override the inner dependency Shot includes in your project during the plugin configuration you can do it as follows:

dependencies {
  ....
  shotDependencies "com.karumi:shot-android:ANY_VERSION_YOU_WANT_TO_USE"
  ....
}

Keep in mind you'll need to use a compatible version or Shot won't work as expected.

ActivityScenario support

ActivityTestRule has been deprecated and now the usage of ActivityScenario is recommended. However, Shot needs to be executed from the instrumentation thread to be able to extract all the test metadata needed to record and verify screenshots. That's why we've created an ActivityScenario extension method named waitForActivity. This extension is needed get the activity instance from the instrumentation thread instead of running Shot from the app target thread. Using this extension you can write tests like this:

class MainActivityTest: ScreenshotTest {
    @Test
    fun rendersTheDefaultActivityState() {
        val activity = ActivityScenario.launch(MainActivity::class.java)

        compareScreenshot(activity)
    }
}

I hope we can find a better solution for this issue in the future.

Executing tests from Android Studio

Shot is a Gradle plugin and it does not integrate with AS by default. After running your tests, Shot Gradle plugin will fetch the screenshots generated during tests' execution and use them to check if your tests are passing or not. You always can run your tests from command line as explained above. However, if you want to run your tests from AS you can create a configuration like this:

asConfig

Keep in mind the debugger may not work if use use this option. If you want to debug your tests you can run them from Android Studio as you'd do with any other instrumentation test and you may need to execute this command before running your test:

adb rm -rf /storage/emulated/0/Download/screenshots/*

Executing tests in multiple devices

If after some time writing screenshot tests your build takes too long to run our recommendation is to run your tests in multiple devices. Sharding your tests execution will split your test suite into different devices so your tests execution time will be reduced. This feature is not designed to test the UI across different platforms or screen resolutions, to do that we'd recommend you to configure the size of the screenshot taken by modifing the view height and width. To run your tests in multiple devices you can use Composer and the official Gradle Plugin they provide. Composer will take all your tests and will split the test suite execution between all the connected devices. Remember, if you are going to use more than one device all the devices should use the same Android OS and the same screen resolution and density! Keep also in mind composer needs Gradle 5.4.1 to be able to run your tests using multiple devices.

Once you've configured composer to run your tests you only need to update Shot to use the composer task as the instrumentation test task as follows:

shot {
  useComposer = true
}

If you are using orchestrator remember to enable it in composer configuration:

composer {
  // ...
  withOrchestrator true
  // ...
}

Tolerance

Shot provides a simple mechanism to be able to configure a threshold value when comparing recorded images with the new ones during the verification stage. You may need to use tolerance in your tests when testing compose components because the API Shot uses to record screenshots depending on the device where your tests are executed. There are other scenarios where you may need to configure a tolerance value, but these are not so common. If you want to configure it you can use this config in your build.gradle file.

shot {
    tolerance =  0.1 // 0,1% tolerance
}

If you configure tolerance = 100 it means the tolerance threshold will be 100% and all your tests will pass even if they should fail...so be careful when configuring this param.

Take into account the instrumentationTestTask could be different if you use different flavors or build types. Remember also you should use Shot > 3.0.0 because this feature was introduced in this release!

CI Reporting

Shot generates an HTML report you can review at the end of the recording or verification build. However, if you are running Shot in a CI environment which does not support saving the reporting files generated by the build you can verify your tests using this command ./gradlew debugExecuteScreenshotTests -PprintBase64. This will change how Shot show comparision errors displaying a command you can copy and paste on your local terminal for every screenshot test failed.

If you want to see only failing tests in output, please add showOnlyFailingTestsInReports = true as an option to your build.gradle.

Running only some tests

You can run a single test or test class, just add the android.testInstrumentationRunnerArguments.class parameter within your gradle call. This option works for both modes, verification and recording, just remember to add the -Precord if you want to do the latter.

Running all tests in a class:

./gradlew <Flavor>>executeScreenshotTests -Pandroid.testInstrumentationRunnerArguments.class=com.your.package.YourClassTest

Running a single test:

./gradlew <Flavor>>executeScreenshotTests -Pandroid.testInstrumentationRunnerArguments.class=com.your.package.YourClassTest#yourTest

Using shot on API 29+

Since Shot 5.8.0 we provide support for devices running API >= 29. There is no need to configure android:requestLegacyExternalStorage="true" or provide any special storage permission in your test ``AndroidManifest`.

Development documentation

Inside this repository you'll find two types of projects. The first one is all the code related to the Gradle Plugin. The second one is all the code related to the example projects we use as consumers of the Gradle Plugin and also as end to end tests. Review the following folders when developing a new feature for Shot or fixing a bug:

Plugin related folders:

  • shot: Main Gradle Plugin module.
  • core: Gradle Plugin independent module where all the shot business logic is placed.
  • shot-android: Android library included in the project where Shot is installed automatically when the Gradle Plugin is initialized.

Consumers and end to end tests folder:

  • shot-consumer: A simple project created to test Shot and show how the library works.
  • shot-consumer-flavors: A simple project focused on testing how the flavors feature works.

When developing a feature or fixing a bug, plugin related folders are the place where most of the code will be. When writing end to end tests you should review the consumers' folders. Unit or integration tests should be added in the first group of folders using all the tooling already installed and configured for you.

When talking about the IDE we should use, our recommendation is simple. We should use IntelliJ Idea for the Gradle Plugin related code and Android Studio for the consumers. Keep in mind the consumers' configuration is not linked with the root Gradle file so you won't be able to build the consumers from the root of this project using Android Studio. That's why we recommend the usage of different IDEs using different root Gradle configurations when working with this repository.

Steps to develop a feature or fix a bug:

  • Review our CONTRIBUTING.md file. There you'll find some general development rules.
  • Open an issue or drop a comment to explain what you'd like to implement or to fix. Communication is really important for us and we recommend dropping a comment or opening an issue before to avoid development issues.
  • Fork this repository and create a new branch where you'll develop the new feature or fix.
  • Install IntelliJ and Android Studio.
  • Import the root Gradle file configuration with IntelliJ. You will have to install the Scala plugin recommended by IntelliJ, but don't worry, as soon as you start IntelliJ you'll see a pop-up with the recommended plugin.
  • Add RELEASE_SIGNING_ENABLED=false to your local properties to be able to install artifacts in your local maven repository without signing them.
  • Develop the code you'd like to implement. Remember to add the unit/integration test coverage to the code you are working on.
  • Execute the Gradle task ./gradlew publishToMavenLocal from the root folder in order to update your plugin local installation.
  • Using Android Studio import shot-android or shot-consumer-flavors and write an example of the feature or fix you coded before. The example test you write will work as an end to end test.
  • Commit and push the code. Our CI configuration will ensure everything is working as expected!
  • Remember to execute ./gradlew publishToMavenLocal whenever you change the Gradle plugin code related in order to update your local repository and be able to use it from the consumers folder.
  • Once you are ready, send a PR. We will review it and help you to contribute to the official repository. Once everything is ready, we will merge it and release a new version.

In case you need to start an Android emulator you have scripts inside the consumers' folder you can execute to create the emulators you'll need to run the tests 😃

This is the list of most useful Gradle tasks you might need divided by type of project:

  • Plugin related tasks:

    • ./gradlew publishToMavenLocal: Install Shot in your local gradle repository.
    • ./gradlew test: Execute all the tests related to the Gradle plugin.
    • ./gradlew scalafmtAll: Review the Gradle Plugin's checkstyle.
  • Consumers related tasks:

    • ./gradlew executeScreenshotTests: Execute all the screenshot tests for the associated consumer in verification mode.
    • ./gradlew executeScreenshotTests -Precord: Execute all the screenshot tests for the associated consumer in record mode.

iOS support

If you want to apply the same testing technique on iOS you can use Swift Snapshot Testing

Developed By

Follow me on Twitter Add me to Linkedin

License

Copyright 2022 Pedro Vicente Gómez Sánchez

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • Running tests from windows throws ``org.apache.commons.io.FileExistsException``

    Running tests from windows throws ``org.apache.commons.io.FileExistsException``

    Expected behaviour

    executeScreenshotTests -Precord and executeScreenshotTests should not throw FileExistsException

    Actual behaviour

    Running command executeScreenshotTests -Precord is returning org.apache.commons.io.FileExistsException: Destination '{myProjectPath}\features\{myFeature}\screenshots\debug\screenshots-compose-default\{packageName}testName.png already exists.

    Running command executeScreenshotTests is returning org.apache.commons.io.FileExistsException: Destination '{myProjectPath}\features\{myFeature}\screenshots\debug\screenshots-compose-default\metadata.json_emulator-5554 already exists.

    NOTE: I deleted the screenshots directory from my module before running these commands. After these commands run and finish I see the .png, metadata.json-5554 and sometimes the metadata.json files in that directory.

    Steps to reproduce

    Create a test using compose-ui and run the commands: gradlew.bat executeScreenshotTests -Precord gradlew.bat executeScreenshotTests

    Version of the library

    5.11.0 Also I am using a machine with Windows 10 installed and Android Studio Arctic Fox 2020.3.1 RC1

    enhancement help wanted 
    opened by mariobat88 34
  • downloadScreenshot failed in devices with API >=29

    downloadScreenshot failed in devices with API >=29

    When executing the Screenshot tests, the tests are actually executed in the emulator but then the gradle tasks fails when downloading screenshots

    `$ ./gradlew executeScreenshotTests --stacktrace
    `
    > Task :designsystemdemoapp:connectedDebugAndroidTest
    Starting 25 tests on Pixel_3a_API_Q(AVD) - 10
    
    > Task :designsystemdemoapp:downloadScreenshots FAILED
    ⬇️  Pulling screenshots from your connected devices!
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':designsystemdemoapp:downloadScreenshots'.
    > Nonzero exit value: 1
    
    * Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Exception is:
    `org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':designsystemdemoapp:downloadScreenshots'.
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:166)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:163)
            at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:156)
            at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
            at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
            at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
            at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
            at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
            at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
            at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
            at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
            at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
            at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
            at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
            at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
            at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
            at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
            at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
            at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
            at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
            at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
            at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
            at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
            at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
            at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
            at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
            at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
            at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
            at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
            at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
            at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    Caused by: java.lang.RuntimeException: Nonzero exit value: 1
            at scala.sys.package$.error(package.scala:27)
            at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:134)
            at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:104)
            at com.karumi.shot.android.Adb.executeAdbCommandWithResult(Adb.scala:33)
            at com.karumi.shot.android.Adb.pullScreenshots(Adb.scala:23)
            at com.karumi.shot.Shot.$anonfun$pullScreenshots$1(Shot.scala:121)
            at com.karumi.shot.Shot.$anonfun$pullScreenshots$1$adapted(Shot.scala:118)
            at scala.collection.immutable.List.foreach(List.scala:389)
            at com.karumi.shot.Shot.pullScreenshots(Shot.scala:118)
            at com.karumi.shot.Shot.$anonfun$downloadScreenshots$1(Shot.scala:40)
            at com.karumi.shot.Shot.$anonfun$downloadScreenshots$1$adapted(Shot.scala:38)
            at com.karumi.shot.Shot.executeIfAppIdIsValid(Shot.scala:103)
            at com.karumi.shot.Shot.downloadScreenshots(Shot.scala:38)
            at com.karumi.shot.tasks.DownloadScreenshotsTask.downloadScreenshots(Tasks.scala:84)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
            at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:49)
            at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
            at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
            at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:717)
            at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:684)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:476)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
            at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:461)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:444)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:93)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:237)
            at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
            at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
            at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
            at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
            at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
            at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
            at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
            at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
            at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
            at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
            at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
            at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
            at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
            at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
            at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:208)
            at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
            at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
            at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
            at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
            at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
            at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
            at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
            at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
            at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
            at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
            at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
            at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
            at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
            at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
            at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
            at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
            at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
            at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:69)
            at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:47)
            at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:140)
            ... 34 more`
    
    
    bug help wanted 
    opened by SisterMorphine 34
  • NullPointerException when there are no screenshot tests

    NullPointerException when there are no screenshot tests

    I'm running the plugin like the documentation says, and am getting this exception. I'm following it through and it looks like the plugin is trying to get screen shots for compose and there are none so there is a NPE.

    Caused by: java.lang.NullPointerException
            at scala.collection.mutable.ArrayOps$ofRef$.newBuilder$extension(ArrayOps.scala:202)
            at scala.collection.mutable.ArrayOps$ofRef.newBuilder(ArrayOps.scala:198)
            at scala.collection.TraversableLike.filterImpl(TraversableLike.scala:289)
            at scala.collection.TraversableLike.filterImpl$(TraversableLike.scala:284)
            at scala.collection.mutable.ArrayOps$ofRef.filterImpl(ArrayOps.scala:198)
            at scala.collection.TraversableLike.filter(TraversableLike.scala:382)
            at scala.collection.TraversableLike.filter$(TraversableLike.scala:382)
            at scala.collection.mutable.ArrayOps$ofRef.filter(ArrayOps.scala:198)
            at com.karumi.shot.Shot.readComposeScreenshotsMetadata(Shot.scala:292)
            at com.karumi.shot.Shot.recordComposeScreenshots(Shot.scala:188)
            at com.karumi.shot.Shot.recordScreenshots(Shot.scala:58)
            at com.karumi.shot.tasks.ExecuteScreenshotTests.executeScreenshotTests(Tasks.scala:73)
    

    This is on version 5.5.0

    Please let me know if I can provide anymore information to you to get this issue resovled.

    bug 
    opened by AndrewReitz 25
  • [ISSUE-78] Test orchestrator support

    [ISSUE-78] Test orchestrator support

    :pushpin: References

    • Issues:
    • #78
    • #262

    :tophat: What is the goal?

    Providing support for AndroidX Orchestrator

    How is it being implemented?

    Compose testing is done by one of the contributor, so we have to only ensure preserving of metadata files. According to default screenshot done by facebook it is needed to move screenshots and metadata files to another temporory dir, because in every starting test screenshot tool from facebook clears screenshots-default dir.

    • Upgrading facebook to 0.14.0 version (Now metadata from facebook are save as json file instead of xml)
    • For default screenshots testing, copying screenshots and metadata files for every finished test into screenshots-default-orchestrated dir on device
    • For compose screenshots testing, copying metadata (screenshots for compose are safe during test with orchestration, no needs to moving) for every finished test into screenshots-default-compose-orchestrated dir on device

    How can it be tested?

    To test it, it would be worth to run record and verification on projects with/without orchestrator.

    • [x] Use case 1: Testing in all shot-consumer-* with orchestrator and without it
    opened by mariuszmarzec 23
  • With ANDROIDX_TEST_ORCHESTRATOR only one screenshot is retrieved

    With ANDROIDX_TEST_ORCHESTRATOR only one screenshot is retrieved

    Expected behaviour

    • record/verify all screenshots

    Actual behaviour

    • only one (latest) screenshot is retrieved

    Steps to reproduce

    • have multiple screenshot tests
    • execute it

    Version of the library

    3.1.0

    For a quick test project, please see: https://github.com/tobiasKaminsky/KarumiTest

    Commenting this https://github.com/tobiasKaminsky/KarumiTest/blob/adea1c075876454da439315eeaf9c9960c563b23/app/build.gradle#L21 will retrieve two screenshots, else only one.

    Gradle task: ./gradlew executeScreenshotTests -Precord

    bug help wanted 
    opened by tobiasKaminsky 20
  • Unkown test name and test class when screenshot is taken from espresso view action

    Unkown test name and test class when screenshot is taken from espresso view action

    Expected behaviour

    There should be a way to give custom test name and test class for report if it can't be detected by library

    Actual behaviour

    In the html report generated test name test class are unknown: Screenshot 2020-10-13 at 2 14 28 PM

    Steps to reproduce

    In order to take screenshot of a view in activity, I invoke the compareScreenshot method from espresso ViewAction as follows:

    fun takeScreenshot(name: String): ViewAction {
        return object: ViewAction {
            override fun getDescription(): String {
                return "Takes screenshot of view"
            }
    
            override fun getConstraints(): Matcher<View> {
                return CoreMatchers.allOf(ViewMatchers.isDisplayed(), ViewMatchers.isAssignableFrom(View::class.java))
            }
    
            override fun perform(uiController: UiController?, view: View) {
                compareScreenshot(view, name = name)
            }
        }
    

    and then I use this ViewAction from test class extending ScreenshotTest as follows:

    @Test
    fun testScreenshotExpanded() {
        val interaction = onView(ViewMatchers.withId(VIEW_ID))
        interaction.perform(takeScreenshot("view"))
    }
    

    Version of the library

    com.karumi:shot:5.1.2

    Am I missing anything here? If not, is there any work around that I can use

    opened by tusharkathuria 18
  • Can not pull record screenshots from the phone to the project on Windows 10

    Can not pull record screenshots from the phone to the project on Windows 10

    Expected behaviour

    Run command to record screenshots and get recorded screenshots in images/recorded folder and screenshots folder in the project on Windows 10

    Actual behaviour

    I didn't see recorded screenshots in my project although terminal of Android Studio notify pulling screenshots successfully

    Steps to reproduce

    1. Run the command on Windows 10: gradlew mockWebServerMobileNativeDebugExecuteScreenshotTests -Precord -Pandroid.testInstrumentationRunnerArguments.class=my_testcase.
    2. Terminal of Android Studio notice that task done successfully. image
    3. The images/record folder doesn't contain record screenshots as my expectation. image The screenshots folder also doesn't contains the record screenshots.

    Version of the library

    4.3.0, 4.4.0

    • I used Gradle 5.4.1.
    • On MacOS 10.15.6, I can run record screenshots command and get the record screenshots.
    enhancement help wanted 
    opened by vnhanh 18
  • Application suffixes are not being handled correctly when testApplicationId is configured

    Application suffixes are not being handled correctly when testApplicationId is configured

    Expected behaviour

    If I run ./gradlew <Flavor><BuildType>ExecuteScreenshotTests -Precord I get all the screenshots recorded and downloaded from the device.

    Actual behaviour

    Build fails with this message:

    Execution failed for task ':app:downloadScreenshots'. Nonzero exit value: 1

    Steps to reproduce

    This is my setup:

    buildTypes {
            debug {
                applicationIdSuffix ".debug"
                versionNameSuffix "-debug"
            }
     }
    
    productFlavors {
        dev {
            applicationIdSuffix ".dev"
            versionNameSuffix "-dev"
        }
    }
    

    Setup for Version 4.0.0:

    shot {
        useComposer = true
    }
    

    Setup for Version 3.1.0:

    shot {
        appId = "my.application.package.dev.debug"
        instrumentationTestTask = "testDevDebugComposer"
    }
    

    It also happens without using composer, by the way.

    Attached the whole exception stacktrace gradleException.txt

    Version of the library

    3.1.0, 4.0.0

    bug 
    opened by fmontesino 18
  • Add a configurable tolerance.

    Add a configurable tolerance.

    Our current implementation compares the recorded screenshots used as a baseline and the new one taken from the device using a pixel-perfect strategy. We should provide a config value we can use to compare the screenshots letting the user consider two screenshots as the same even if some pixels are not the same. This is the code we should modify. I'd count the number of different pixels as a percentage before considering the comparison as a failure. The tolerance value should be easily configured from the build.gradle file.

    enhancement help wanted 
    opened by pedrovgs 15
  • Cannot pull screenshots from phone

    Cannot pull screenshots from phone

    Expected behaviour

    Run ./gradlew executeScreenshotTests -Precord and fetch screenshots from phone.

    Actual behaviour

    I'm trying to create the snapshots but Shot cannot pull screenshots from phone.

    Here is the log from Gradle:

    > Task :app:debugDownloadScreenshots
    ⬇️  Pulling screenshots from your connected devices!
    Shot ADB warning: We could not pull screenshots from folder: /sdcard/screenshots/br.com.zup.shottestapp.test/screenshots-default/
    Shot ADB warning: We could not pull screenshots from folder: /sdcard/screenshots/br.com.zup.shottestapp.test/screenshots-compose-default/
    Shot ADB warning: rm: /sdcard/screenshots/br.com.zup.shottestapp.test/screenshots-default/: No such file or directory
    Shot ADB warning: rm: /sdcard/screenshots/br.com.zup.shottestapp.test/screenshots-compose-default/: No such file or directory
    
    > Task :app:debugExecuteScreenshotTests FAILED
    💾  Saving screenshots.
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:debugExecuteScreenshotTests'.
    > java.lang.NullPointerException (no error message)
    

    Steps to reproduce

    Just create new project, follow the steps on README.md and run the command ./gradlew executeScreenshotTests -Precord and the error will occur.

    Version of the library

    5.3.0

    bug help wanted 
    opened by tuliopereirazup 14
  • NPE recording screenshots

    NPE recording screenshots

    I want to run yours plugin I do: ./gradlew executeScreenshotTests -Precord

    But get some errors:

    ⬇️  Pulling screenshots from your connected devices!
    
    > Task :presentation:executeScreenshotTests FAILED
    💾  Saving screenshots.
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':presentation:executeScreenshotTests'.
    > java.io.FileNotFoundException: /Users/ivan/AndroidStudioProjects/android-client/presentation/screenshots/screenshots-default/com.kg.project.presentation.RegressSuite_test_dump.json (No such file or directory)
    

    But I found this Json at zip archive screenshot_bundle.zip

    What I should do to avoid this error?

    Thanks in advance

    Version of the library

    com.karumi:shot:3.0.2

    bug help wanted 
    opened by slacklab 13
  • Removing the Toolbar shadow (elevation)

    Removing the Toolbar shadow (elevation)

    Expected behaviour

    When doing screenshots of composables, the screenshot should not have display the shadow of the Toolbar

    Actual behaviour

    When doing screenshots of composables there is gradient (shadow) at the top of the image. image

    Steps to reproduce

    • Create an compose snapshot test
    @get:org.junit.Rule
    val composeRule = androidx.compose.ui.test.junit4.createComposeRule()
    
    @org.junit.Test
    fun testContent() {
        composeRule.setContent { $PREVIEW_NAME$() }
        compareScreenshot(composeRule)
    }
    
    • Record the screenshots

    • Open the screenshots

    Version of the library

    5.14.1

    Using emulator with Android 32

    opened by ivannarino 1
  • Generated diff image does not show all differences

    Generated diff image does not show all differences

    We have a lot of red/reddish elements in the UI of our app and we realised that changes in those elements are not reflected in the diff images of the Shot verification report.

    ℹ️ This test result shows a screenshot test in which an orange button has been moved slightly downwards. The change is correctly identified by Shot, but it's not clear from the diff image.

    image

    Expected behaviour

    All differences between the original and the new screenshot are visible in the diff images in the verification report.

    Actual behaviour

    Differences of some elements are not visible in the diff images in the verification report: This mostly happens with red elements. But in the example below it also happens for green and blue elements when they are placed on black background.

    Steps to reproduce

    I created a test with a simple UI to reproduce the problem:

    package example.test
    
    import android.graphics.Color
    import android.view.Gravity
    import android.widget.LinearLayout
    import android.widget.TextView
    import androidx.test.platform.app.InstrumentationRegistry
    import com.karumi.shot.ScreenshotTest
    import org.junit.Test
    
    class ColorScreenshotTest : ScreenshotTest {
    
        private val textViewGravity = Gravity.LEFT  // change to Gravity.RIGHT for the verification run
    
        @Test
        fun colorTestBlack() {
            actualTest(backgroundColor = Color.BLACK)
        }
    
        @Test
        fun colorTestWhite() {
            actualTest(backgroundColor = Color.WHITE)
        }
    
        private fun actualTest(backgroundColor: Int) {
            val context = InstrumentationRegistry.getInstrumentation().targetContext
    
            val view = LinearLayout(context).apply {
                orientation = LinearLayout.VERTICAL
                setBackgroundColor(backgroundColor)
    
                addView(
                    TextView(context).apply {
                        textSize = 30f
                        text = "Red text"
                        setTextColor(Color.RED)
    
                        gravity = textViewGravity
                    }
                )
    
                addView(
                    TextView(context).apply {
                        textSize = 30f
                        text = "Green text"
                        setTextColor(Color.GREEN)
    
                        gravity = textViewGravity
                    }
                )
    
                addView(
                    TextView(context).apply {
                        textSize = 30f
                        text = "Blue text"
                        setTextColor(Color.BLUE)
    
                        gravity = textViewGravity
                    }
                )
            }
    
            compareScreenshot(
                view = view,
                heightInPx = 500,
                widthInPx = 500
            )
        }
    }
    

    image

    Version of the library

    5.14.1

    More information

    I guess that this is related to the RedComposite from the scrimage library which is used to merge the original and the new screenshot to create the diff image.

    https://github.com/pedrovgs/Shot/blob/4f609da98f172b4c49f11f65a989385a7b407177/core/src/main/scala/com/karumi/shot/screenshots/ScreenshotsDiffGenerator.scala#L37

    opened by simonwalter 0
  • Waiting for remote image fetch

    Waiting for remote image fetch

    Expected behaviour

    For reference, I am using Coil to load images over the network. I've provided each of these images with a fallback and a loading state via the code below:

    @Composable
    fun AsyncImageStateful(
        modifier: Modifier = Modifier,
        image: String,
        fallback: Painter,
        contentScale: ContentScale,
        contentDescription: String = ""
    ) {
        SubcomposeAsyncImage(
            modifier = modifier,
            model = ImageRequest.Builder(context = LocalContext.current)
                .data(
                    data = image
                )
                .decoderFactory(
                    factory = SvgDecoder.Factory()
                )
                .crossfade(enable = true)
                .build(),
            contentDescription = contentDescription,
            contentScale = contentScale,
            alignment = Alignment.TopCenter
        ) {
            when (painter.state) {
                is AsyncImagePainter.State.Loading -> {
                    Box(
                        modifier = modifier
                            .placeholder(
                                visible = true,
                                color = Charcoal100,
                                highlight = PlaceholderHighlight.shimmer(
                                    highlightColor = Color.White
                                )
                            )
                    )
                }
                is AsyncImagePainter.State.Success -> {
                    SubcomposeAsyncImageContent()
                }
                else -> {
                    SubcomposeAsyncImageContent(
                        painter = fallback
                    )
                }
            }
        }
    }
    

    This essentially adds my shimmer when the image is loading, and reverts to the provided fallback image if the image doesn't load or doesn't point to anything.

    I expect there to be a way to wait for this to complete before taking the snapshot.

    Actual behaviour

    I am seeing inconsistent behavior where sometimes the snapshots complete with an actual image (when a real URL is provided) and some complete with the fallback image (when the URL is invalid) and some don't complete at all (remains in loading). This causes my snapshots to inconsistently fail for different reasons.

    I have tried adding coroutine delays in prepareUIForScreenshot without any luck. I don't know how else to have it wait so these remain consistent.

    Steps to reproduce

    1. Add accompanist placeholder and coil to app build.gradle
    implementation 'com.google.accompanist:accompanist-placeholder:0.28.0'`
    implementation 'io.coil-kt:coil-compose:2.2.2'
    implementation 'io.coil-kt:coil-svg:2.2.2'
    
    1. Use the above composable in a snapshot test
    AsyncImageStateful(
        modifier = Modifier
            .size(
                width = 95.dp,
                height = 85.dp
            )
            .clip(shape = RoundedCornerShape(size = 8.dp))
            .loadingPlaceholder(visible = displayModel.isLoading),
        image = displayModel.image,
        contentScale = ContentScale.Crop,
        contentDescription = "${displayModel.name} Image",
        fallback = painterResource(id = R.drawable.fallback)
    )
    
    1. Provide a fallback image (i.e. R.drawable.fallback)
    2. Record the snapshots
    3. Observe that verification of snapshots sometimes fails due to the image not loading in time

    Version of the library

    Shot 5.14.1

    opened by DerekBeam 0
  • Screenshots get deleted after being recorded.

    Screenshots get deleted after being recorded.

    Expected behaviour

    I expect after running ./gradlew executeScreenshotTests -Precord that the tests get saved and stay in the directory they're saved in.

    Actual behaviour

    The entire directory gets deleted, and a new empty directory gets created in projects' build/reports/shot/debug/record/images/recorded. It has screenshots-default and screenshots-compose-default, but both are empty. It also has an index.html and that says 0 screenshot tests were run.

    Steps to reproduce

    run /gradlew executeScreenshotTests -Precord

    Version of the library

    I'm using Shot 5.14.1

    My setup is as follows: I tried to follow the instruments as closely as possible. I have an AndroidManifest test file that declares sharedUserId, and I have declared that same id in app/AndroidManifest. in my project build.gradle I have declared in my dependencies classpath 'com.karumi:shot:5.14.1' My test runner is testInstrumentationRunner "com.karumi.shot.ShotTestRunner"

    I've applied everything in the get started section possible (I think)

    What I get is

    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

    The odd thing is, after it deletes the directories then I get this error ☝️ , but if I add them back in manually and then run /gradlew executeScreenshotTests -Precord then it returns everything was successful, except it deletes everything... lol I see the files be generated then immediately deleted.

    Task :app:debugExecuteScreenshotTests 💾 Saving screenshots. 😃 Screenshots recorded and saved at: /Users/chrisjohnson/StudioProjects/project/app/screenshots/debug/ 🤓 You can review the execution report here: /Users/chrisjohnson/StudioProjects/project/app/build/reports/shot/debug/index.html

    My test is basic, with some infrastructure around compose.

    class MessagesScreenTest : BaseComposeScreenTest<MessagesUiState, MessagesViewModel, UiEvent.Default>(
        MessagesUiState()
    ), ScreenshotTest {
    
        @Test
        fun testMessagesScreenShot() {
            setContent { viewModel ->
                MessagesScreen(viewModel = viewModel)
                updateUiState {
                    it.copy(toolbarTitle = "test")
                }
            }
            compareScreenshot(composeTestRule)
        }
    }
    
    opened by cj1098 0
  • How to compare screens with dynamic content

    How to compare screens with dynamic content

    Steps to reproduce

    I have some screens with dynamic image and text. Example - date that changes everyday. How can I use shot plugin to compare the screens with dynamic content?

    Version of the library

    5.14.1

    opened by saranyas72 0
  • Snapshot on multipe devices only saving last screenshot

    Snapshot on multipe devices only saving last screenshot

    Expected behaviour

    I am trying to run a tablet emulator and phone emulator. I expect two screenshots in my /app/screenshots/debug folder (1 for tablet and 1 for phone)

    Actual behaviour

    Only getting one screenshot, but the test is executing on both simulators. Seems like the last finishing emulator is the only screenshot thats saved.

    Steps to reproduce

    ./emulator -avd Pixel_C_API_30 ./emulator -avd PixelXL_Emulator

    ./gradlew executeScreenshotTests -Precord

    Version of the library

    com.karumi:shot:5.14.1 Java 11

    opened by Mittchel 1
Releases(5.14.1)
Owner
Pedro Gómez
"Sometimes it is the people no one imagines anything of who do the things no one can imagine." - Alan Turing
Pedro Gómez
The Privacy Friendly QR Scanner belongs to the group of Privacy Friendly Apps

Privacy Friendly QR Scanner The Privacy Friendly QR Scanner belongs to the group of Privacy Friendly Apps. The app supports its users in detecting mal

SECUSO 198 Dec 30, 2022
A Full-Stack mobile app, including Android & Server, Simple-Poem 简诗. You can write poem in graceful & traditional Chinese style.

JianShi 简诗 A Full-Stack mobile app, including Android side & Server side, Simple-Poem 简诗. You can write poem in graceful & traditional Chinese style.

wingjay 1.9k Jan 6, 2023
Sunlight Apk - Sunlight App where You can decide Your Mood and Relative suggestions of what you can do will be displayed

Sunlight_Apk This Is a App where You can decide Your Mood and Relative suggestio

Jadu 1 Feb 5, 2022
AnimApp is an app that recommends you random anime and you can add it to your favourite if you like it.

papb-team6 AnimApp is an app that recommends you animes and you can add it to your favourite if you like it. Team members: Firdaus Bisma Suryakusuma (

Gilang Adhitama Putra 1 Mar 9, 2022
when you use restful api and network get disconnect you have to store your data local for make your app faster and work on ofline mode

AppArchitectureOflineMode when you use restful api and network get disconnect you have to store your data local for make your app faster and work on o

Kareem-Mansy 3 Jun 20, 2021
An Android base project building on MVVM Architecture Pattern. This can help you build new apps faster

MVVM Explanation If you can't imagine what is MVVM, please read my medium article here first. It can fully explain the revolution of Software architec

Danh Dev 29 Sep 21, 2022
With this simple app, you can keep track of your favourite cryptocurrency on your wrist.

Capstone project crypto Tracker ?? Final Product (05-06) V1.1 "somebody toucha my spaghet" feature set State Note Track the current price of a crypto

Stefan de Kraker 2 Aug 20, 2022
A news application through which you can learn and browse all the news that interests you by choosing the country and type of news with the ability to browse and add some news to your favorites

MY-NEWS-Android A news application through which you can learn and browse all the news that interests you by choosing the country and type of news wit

Mahmoud ELramady 0 Nov 11, 2021
An Open-Source repository that contains all the Android Dev and Kotlin concepts and several projects on android ranging in difficulty making this repo completely beginner-friendly.

An Open-Source repository that contains all the Android Dev and Kotlin concepts and several projects on android ranging in difficulty making this repo completely beginner-friendly. The main aim of this repository is to help students who are learning Android Development or preparing for an Android Developer role-based job.

Mimo Patra 15 Dec 29, 2022
The easy way to use biometric authentication in your Flutter app. Supports Fingerprint, FaceID and Iris.

BiometricX The easy way to use biometric authentication in your Flutter app. Supports Fingerprint, FaceID and Iris. Demo APK. Starting $ flutter pub a

Salman S 13 Dec 15, 2022
Android app that helps you keep track of the medical supplements you need to take and how you spend your days

Android app that helps you keep track of the medical supplements you need to take and how you spend your days, similar to a bullet journal. It also allows you to reflect on your day, week, year, etc.

Rachelle Hu 4 Nov 10, 2022
⌨️ A tool that gives you a massive head start when building Compose based apps. It saves you from time-consuming setup and configuration

⌨️ A tool that gives you a massive head start when building Compose based apps. It saves you from time-consuming setup and configuration

theapache64 467 Dec 23, 2022
Read and write Android/data files on Android 13 without root

Android 13 (Tiramisu API 33) Read and write /Android/data or /Android/obb not need root Android 13 read and write /Android/data or /Android/obb withou

FolderV 59 Jan 4, 2023
🚀A powerful android clean architecture that helps you build your apps faster.

IMStudio ?? Table of Contents Project Structure Convention RxJava Common Scripts Technical Stack Dependencies Library Architecture Case Study Authors

Hau NGUYEN (Leo) 0 Nov 20, 2022
A simple xposed module that helps you use your AdGuard subscription in multiple devices

DualGuard A simple xposed module that helps you use your AdGuard subscription in multiple (>3) devices. Monstor ahead! / 警告 This is NOT a module that

null 7 Oct 2, 2022
Kalam is an app that gives people a chance to write their stories on the app.

Kalam is an app that gives people a chance to write their stories on the app. This app gives a good story for the story readers and gives good story writers a chance to write their own story

Uday Chugh 0 Apr 26, 2022
A movie application where you can search a movie that you want and see the detail of movie

MovieApp This is a simple movie application where you can search a movie that you want and see the detail of movie Technologies Hilt (Dependency Injec

Serhad Mert 5 Nov 30, 2021
This is the kotlin-based android application. In this you can solve upto 100 flag-quiz question and enhance your skill.

Flag Quiz App - DOWNLOAD APP Enhance your knowledge by taking part in this Quiz - 100 Questions in 30 minutes It is based on the Kotlin language. You

Suryansh Prajapati 5 Dec 19, 2022