creating custom tasks to record and verify screenshot

- introduces a 'screenshot' flag to include/exclude the screenshot tests from the default test runs
This commit is contained in:
Adam Brown 2022-09-14 14:05:40 +01:00
parent 9ef4975025
commit 0f19726fe2
2 changed files with 24 additions and 1 deletions

View File

@ -296,3 +296,25 @@ dependencyAnalysis {
}
}
}
task recordScreenshots(type: GradleBuild) {
startParameter.projectProperties.screenshot = ""
tasks = [':vector:recordPaparazziGplayDebug']
}
task verifyScreenshots(type: GradleBuild) {
startParameter.projectProperties.screenshot = ""
tasks = [':vector:verifyPaparazziGplayDebug']
}
ext.initScreenshotTests = { project ->
project.apply plugin: 'app.cash.paparazzi'
project.android.testOptions.unitTests.all {
def screenshotTestCapture = "**/*ScreenshotTest*"
if (project.hasProperty("screenshot")) {
include screenshotTestCapture
} else {
exclude screenshotTestCapture
}
}
}

View File

@ -3,7 +3,6 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'app.cash.paparazzi'
if (project.hasProperty("coverage")) {
apply plugin: 'jacoco'
@ -25,6 +24,8 @@ project.android.buildTypes.all { buildType ->
]
}
initScreenshotTests(project)
android {
// Due to a bug introduced in Android gradle plugin 3.6.0, we have to specify the ndk version to use
// Ref: https://issuetracker.google.com/issues/144111441