From 0f19726fe21e6049b2819d48524a2ba32d29edcc Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 14 Sep 2022 14:05:40 +0100 Subject: [PATCH] creating custom tasks to record and verify screenshot - introduces a 'screenshot' flag to include/exclude the screenshot tests from the default test runs --- build.gradle | 22 ++++++++++++++++++++++ vector/build.gradle | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 479a6b6e25..0e87ab51be 100644 --- a/build.gradle +++ b/build.gradle @@ -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 + } + } +} diff --git a/vector/build.gradle b/vector/build.gradle index 61190a2fa2..ff0d907212 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -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