Git Product home page Git Product logo

paparazzi's Introduction

Paparazzi

An Android library to render your application screens without a physical device or emulator.

class LaunchViewTest {
  @get:Rule
  val paparazzi = Paparazzi(
    deviceConfig = PIXEL_5,
    theme = "android:Theme.Material.Light.NoActionBar"
    // ...see docs for more options
  )

  @Test
  fun launchView() {
    val view = paparazzi.inflate<LaunchView>(R.layout.launch)
    // or...
    // val view = LaunchView(paparazzi.context)

    view.setModel(LaunchModel(title = "paparazzi"))
    paparazzi.snapshot(view)
  }

  @Test
  fun launchComposable() {
    paparazzi.snapshot {
      MyComposable()
    }
  }
}

See the project website for documentation and APIs.

Tasks

$ ./gradlew sample:testDebug

Runs tests and generates an HTML report at sample/build/reports/paparazzi/ showing all test runs and snapshots.

$ ./gradlew sample:recordPaparazziDebug

Saves snapshots as golden values to a predefined source-controlled location (defaults to src/test/snapshots).

$ ./gradlew sample:verifyPaparazziDebug

Runs tests and verifies against previously-recorded golden values. Failures generate diffs at sample/out/failures.

For more examples, check out the sample project.

Git LFS

It is recommended you use Git LFS to store your snapshots. Here's a quick setup:

$ brew install git-lfs
$ git config core.hooksPath  # optional, confirm where your git hooks will be installed
$ git lfs install --local
$ git lfs track "**/snapshots/**/*.png"
$ git add .gitattributes

On CI, you might set up something like:

$HOOKS_DIR/pre-receive

# compares files that match .gitattributes filter to those actually tracked by git-lfs
diff <(git ls-files ':(attr:filter=lfs)' | sort) <(git lfs ls-files -n | sort) >/dev/null

ret=$?
if [[ $ret -ne 0 ]]; then
  echo >&2 "This remote has detected files committed without using Git LFS. Run 'brew install git-lfs && git lfs install' to install it and re-commit your files.";
  exit 1;
fi

your_build_script.sh

if [[ is running snapshot tests ]]; then
  # fail fast if files not checked in using git lfs
  "$HOOKS_DIR"/pre-receive
  git lfs install --local
  git lfs pull
fi

Jetifier

If using Jetifier to migrate off Support libraries, add the following to your gradle.properties to exclude bundled Android dependencies.

android.jetifier.ignorelist=android-base-common,common

Releases

Our change log has release history.

Using plugin application:

buildscript {
  repositories {
    mavenCentral()
    google()
  }
  dependencies {
    classpath 'app.cash.paparazzi:paparazzi-gradle-plugin:1.0.0'
  }
}

apply plugin: 'app.cash.paparazzi'

Using the plugins DSL:

plugins {
  id 'app.cash.paparazzi' version '1.0.0'
}

Snapshots of the development version are available in Sonatype's snapshots repository.

 repositories {
   // ...
   maven {
     url 'https://oss.sonatype.org/content/repositories/snapshots/'
   }
 }

License

Copyright 2019 Square, Inc.

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.

paparazzi's People

Contributors

jrodbx avatar swankjesse avatar twisterrob avatar luis-cortes avatar geoff-powell avatar dnihze avatar menny avatar gamepro65 avatar dependabot[bot] avatar fcduarte avatar liutikas avatar oldergod avatar nak5ive avatar rojanthomas avatar egorand avatar sebastienrouif avatar saket avatar mattprecious avatar msfjarvis avatar rcollet avatar yschimke avatar veyndan avatar autonomousapps avatar tasomaniac avatar paulwoitaschek avatar nicbell avatar guelo avatar luk1709 avatar kirillzh avatar jamesmosley55 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.