물리적 장치 나 에뮬레이터없이 애플리케이션 화면을 렌더링하는 Android 라이브러리.
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 ()
}
}
}문서 및 API는 프로젝트 웹 사이트를 참조하십시오.
./gradlew sample:testDebug 테스트를 실행하고 sample/build/reports/paparazzi/ 에서 HTML 보고서를 생성합니다. 모든 테스트 실행 및 스냅 샷을 보여줍니다.
./gradlew sample:recordPaparazziDebug 스냅 샷을 골든 값으로 미리 정의 된 소스 제어 위치에 저장합니다 (기본값으로 src/test/snapshots ).
./gradlew sample:verifyPaparazziDebug 테스트를 실행하고 이전에 기록 된 황금 값에 대해 검증합니다. 실패는 sample/build/paparazzi/failures 에서 차이를 생성합니다.
더 많은 예를 보려면 샘플 프로젝트를 확인하십시오.
Git LFS를 사용하여 스냅 샷을 저장하는 것이 좋습니다. 다음은 빠른 설정입니다.
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 .gitattributesCI에서는 다음과 같은 것을 설정할 수 있습니다.
$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를 사용하여 지원 라이브러리를 마이그레이션하는 경우 gradle.properties 에 다음을 추가하여 번들 된 Android 종속성을 제외하십시오.
android.jetifier.ignorelist =android-base-common,common로티 애니메이션 스크린 샷을 찍을 때는 로티가 배경 스레드에서 실행되지 않도록 강요해야합니다. 그렇지 않으면 파파라치가 예외 #494, #630을 던질 수 있습니다.
@Before
fun setup () {
LottieTask . EXECUTOR = Executor ( Runnable ::run)
} GoogleMap() 와 같은 일부 컴포테이블은 LocalInspectionMode @Preview -safe composable 로의 단락으로 확인하십시오.
그러나 Paparazzi는 LocalInspectionMode 전 세계적으로 설정하지 않으며 스냅 샷이 레거시보기의 View.isInEditMode 무시하는 방식과 유사하게 실제 생산 출력을 나타냅니다.
해결 방법으로 CompositionLocalProvider 사용하여 ComposionLocalProvider를 사용하여 Composeable으로 이러한 합성 가능한 것을 래핑하고 LocalInspectionMode 설정하는 것이 좋습니다.
@Test
fun inspectionModeView () {
paparazzi.snapshot(
CompositionLocalProvider ( LocalInspectionMode provides true ) {
YourComposable ()
}
)
}우리의 변화 로그에는 릴리스 이력이 있습니다.
플러그인 응용 프로그램 사용 :
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath ' app.cash.paparazzi:paparazzi-gradle-plugin:1.3.5 '
}
}
apply plugin : ' app.cash.paparazzi '플러그인 DSL 사용 :
plugins {
id ' app.cash.paparazzi ' version ' 1.3.5 '
} 개발 버전의 스냅 샷은 Sonatype의 snapshots 저장소에서 사용할 수 있습니다.
repositories {
// ...
maven {
url ' https://oss.sonatype.org/content/repositories/snapshots/ '
}
} 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.