From a693a465eca2bd23033fb513abf56dfa4e3425b1 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Thu, 18 May 2023 23:36:27 -0400 Subject: [PATCH 1/4] Modernize AGP integration This updates the gradle plugin to use modern AGP components APIs for reacting to variants. This allows not relying on `internal` packages and also fixes the plugin's race condition that requires it to be applied after the android plugin. --- .../takahirom/roborazzi/RoborazziPlugin.kt | 143 +++++++++--------- 1 file changed, 74 insertions(+), 69 deletions(-) diff --git a/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt b/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt index bce2f740f..23182135a 100644 --- a/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt +++ b/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt @@ -1,8 +1,9 @@ package io.github.takahirom.roborazzi import android.util.JsonWriter -import com.android.build.gradle.LibraryExtension -import com.android.build.gradle.internal.dsl.BaseAppModuleExtension +import com.android.build.api.variant.AndroidComponentsExtension +import com.android.build.api.variant.ApplicationAndroidComponentsExtension +import com.android.build.api.variant.LibraryAndroidComponentsExtension import java.util.Locale import org.gradle.api.DefaultTask import org.gradle.api.Plugin @@ -25,92 +26,96 @@ class RoborazziPlugin : Plugin { val recordVariants = project.tasks.register("recordRoborazzi") val verifyAndRecordVariants = project.tasks.register("verifyAndRecordRoborazzi") - val hasLibraryPlugin = project.pluginManager.hasPlugin("com.android.library") - val variants = if (hasLibraryPlugin) { - project.extensions.getByType(LibraryExtension::class.java) - .libraryVariants - } else { - project.extensions.getByType(BaseAppModuleExtension::class.java) - .applicationVariants - } - variants.all { variant -> - val variantSlug = variant.name.capitalize(Locale.US) + fun AndroidComponentsExtension<*, *, *>.configureComponents() { + onVariants { variant -> + val unitTest = variant.unitTest ?: return@onVariants + val variantSlug = variant.name.capitalizeUS() // val reportOutputDir = project.layout.buildDirectory.dir("reports/roborazzi") // val snapshotOutputDir = project.layout.projectDirectory.dir("src/test/snapshots") - val testVariantSlug = variant.unitTestVariant.name.capitalize(Locale.US) + val testVariantSlug = unitTest.name.capitalizeUS() - val recordTaskProvider = - project.tasks.register("recordRoborazzi$variantSlug", RoborazziTask::class.java) { - it.group = VERIFICATION_GROUP - } - recordVariants.configure { it.dependsOn(recordTaskProvider) } - - val compareReportGenerateTaskProvider = - project.tasks.register( - "compareRoborazzi$variantSlug", - CompareReportGenerateTask::class.java - ) { - it.group = VERIFICATION_GROUP - it.inputResultJsonsDir.set(project.file(RoborazziReportConst.compareReportDirPath)) - it.outputJsonFile.set(project.file(RoborazziReportConst.compareSummaryReportFilePath)) - } - compareVariants.configure { it.dependsOn(compareReportGenerateTaskProvider) } + val recordTaskProvider = + project.tasks.register("recordRoborazzi$variantSlug", RoborazziTask::class.java) { + it.group = VERIFICATION_GROUP + } + recordVariants.configure { it.dependsOn(recordTaskProvider) } + + val compareReportGenerateTaskProvider = + project.tasks.register( + "compareRoborazzi$variantSlug", + CompareReportGenerateTask::class.java + ) { + it.group = VERIFICATION_GROUP + it.inputResultJsonsDir.set(project.file(RoborazziReportConst.compareReportDirPath)) + it.outputJsonFile.set(project.file(RoborazziReportConst.compareSummaryReportFilePath)) + } + compareVariants.configure { it.dependsOn(compareReportGenerateTaskProvider) } - val verifyTaskProvider = - project.tasks.register("verifyRoborazzi$variantSlug", RoborazziTask::class.java) { - it.group = VERIFICATION_GROUP - } - verifyVariants.configure { it.dependsOn(verifyTaskProvider) } + val verifyTaskProvider = + project.tasks.register("verifyRoborazzi$variantSlug", RoborazziTask::class.java) { + it.group = VERIFICATION_GROUP + } + verifyVariants.configure { it.dependsOn(verifyTaskProvider) } - val verifyAndRecordTaskProvider = - project.tasks.register("verifyAndRecordRoborazzi$variantSlug", RoborazziTask::class.java) { - it.group = VERIFICATION_GROUP + val verifyAndRecordTaskProvider = + project.tasks.register("verifyAndRecordRoborazzi$variantSlug", RoborazziTask::class.java) { + it.group = VERIFICATION_GROUP + } + verifyAndRecordVariants.configure { it.dependsOn(verifyAndRecordTaskProvider) } + + val isRecordRun = project.objects.property(Boolean::class.java) + val isVerifyRun = project.objects.property(Boolean::class.java) + val isCompareRun = project.objects.property(Boolean::class.java) + val isVerifyAndRecordRun = project.objects.property(Boolean::class.java) + + project.gradle.taskGraph.whenReady { graph -> + isRecordRun.set(recordTaskProvider.map { graph.hasTask(it) }) + isVerifyRun.set(verifyTaskProvider.map { graph.hasTask(it) }) + isVerifyAndRecordRun.set(verifyAndRecordTaskProvider.map { graph.hasTask(it) }) + isCompareRun.set(compareReportGenerateTaskProvider.map { graph.hasTask(it) }) } - verifyAndRecordVariants.configure { it.dependsOn(verifyAndRecordTaskProvider) } - - val isRecordRun = project.objects.property(Boolean::class.java) - val isVerifyRun = project.objects.property(Boolean::class.java) - val isCompareRun = project.objects.property(Boolean::class.java) - val isVerifyAndRecordRun = project.objects.property(Boolean::class.java) - - project.gradle.taskGraph.whenReady { graph -> - isRecordRun.set(recordTaskProvider.map { graph.hasTask(it) }) - isVerifyRun.set(verifyTaskProvider.map { graph.hasTask(it) }) - isVerifyAndRecordRun.set(verifyAndRecordTaskProvider.map { graph.hasTask(it) }) - isCompareRun.set(compareReportGenerateTaskProvider.map { graph.hasTask(it) }) - } - val testTaskProvider = project.tasks.named("test$testVariantSlug", Test::class.java) { test -> + val testTaskProvider = project.tasks.named("test$testVariantSlug", Test::class.java) { test -> // test.outputs.dir(reportOutputDir) // test.outputs.dir(snapshotOutputDir) - val roborazziProperties = - project.properties.filterKeys { it.startsWith("roborazzi") } - val compareReportDir = project.file(RoborazziReportConst.compareReportDirPath) - - test.doFirst { - test.systemProperties["roborazzi.test.record"] = - isRecordRun.get() || isVerifyAndRecordRun.get() - test.systemProperties["roborazzi.test.compare"] = isCompareRun.get() - test.systemProperties["roborazzi.test.verify"] = - isVerifyRun.get() || isVerifyAndRecordRun.get() - test.systemProperties.putAll(roborazziProperties) - if (isCompareRun.get()) { - compareReportDir.deleteRecursively() - compareReportDir.mkdirs() + val roborazziProperties = + project.properties.filterKeys { it.startsWith("roborazzi") } + val compareReportDir = project.file(RoborazziReportConst.compareReportDirPath) + + test.doFirst { + test.systemProperties["roborazzi.test.record"] = + isRecordRun.get() || isVerifyAndRecordRun.get() + test.systemProperties["roborazzi.test.compare"] = isCompareRun.get() + test.systemProperties["roborazzi.test.verify"] = + isVerifyRun.get() || isVerifyAndRecordRun.get() + test.systemProperties.putAll(roborazziProperties) + if (isCompareRun.get()) { + compareReportDir.deleteRecursively() + compareReportDir.mkdirs() + } } } + + recordTaskProvider.configure { it.dependsOn(testTaskProvider) } + compareReportGenerateTaskProvider.configure { it.dependsOn(testTaskProvider) } + verifyTaskProvider.configure { it.dependsOn(testTaskProvider) } + verifyAndRecordTaskProvider.configure { it.dependsOn(testTaskProvider) } } + } - recordTaskProvider.configure { it.dependsOn(testTaskProvider) } - compareReportGenerateTaskProvider.configure { it.dependsOn(testTaskProvider) } - verifyTaskProvider.configure { it.dependsOn(testTaskProvider) } - verifyAndRecordTaskProvider.configure { it.dependsOn(testTaskProvider) } + project.pluginManager.withPlugin("com.android.application") { + project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).configureComponents() + } + project.pluginManager.withPlugin("com.android.library") { + project.extensions.getByType(LibraryAndroidComponentsExtension::class.java).configureComponents() } } + private fun String.capitalizeUS() = replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.US) else it.toString() } + open class RoborazziTask : DefaultTask() { @Option( option = "tests", From 5b5f91b0775de79f27d87040a7a6173d3a17c2f4 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Fri, 19 May 2023 14:14:31 -0400 Subject: [PATCH 2/4] Lazily configure task --- .../takahirom/roborazzi/RoborazziPlugin.kt | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt b/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt index 23182135a..7e05af948 100644 --- a/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt +++ b/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt @@ -77,27 +77,29 @@ class RoborazziPlugin : Plugin { isCompareRun.set(compareReportGenerateTaskProvider.map { graph.hasTask(it) }) } - val testTaskProvider = project.tasks.named("test$testVariantSlug", Test::class.java) { test -> -// test.outputs.dir(reportOutputDir) -// test.outputs.dir(snapshotOutputDir) - - val roborazziProperties = - project.properties.filterKeys { it.startsWith("roborazzi") } - val compareReportDir = project.file(RoborazziReportConst.compareReportDirPath) - - test.doFirst { - test.systemProperties["roborazzi.test.record"] = - isRecordRun.get() || isVerifyAndRecordRun.get() - test.systemProperties["roborazzi.test.compare"] = isCompareRun.get() - test.systemProperties["roborazzi.test.verify"] = - isVerifyRun.get() || isVerifyAndRecordRun.get() - test.systemProperties.putAll(roborazziProperties) - if (isCompareRun.get()) { - compareReportDir.deleteRecursively() - compareReportDir.mkdirs() + val testTaskProvider = project.tasks.withType(Test::class.java) + .matching { it.name == "test$testVariantSlug" } + .configureEach { test -> + // test.outputs.dir(reportOutputDir) + // test.outputs.dir(snapshotOutputDir) + + val roborazziProperties = + project.properties.filterKeys { it.startsWith("roborazzi") } + val compareReportDir = project.file(RoborazziReportConst.compareReportDirPath) + + test.doFirst { + test.systemProperties["roborazzi.test.record"] = + isRecordRun.get() || isVerifyAndRecordRun.get() + test.systemProperties["roborazzi.test.compare"] = isCompareRun.get() + test.systemProperties["roborazzi.test.verify"] = + isVerifyRun.get() || isVerifyAndRecordRun.get() + test.systemProperties.putAll(roborazziProperties) + if (isCompareRun.get()) { + compareReportDir.deleteRecursively() + compareReportDir.mkdirs() + } + } } - } - } recordTaskProvider.configure { it.dependsOn(testTaskProvider) } compareReportGenerateTaskProvider.configure { it.dependsOn(testTaskProvider) } From 02f1f75e4cfea47bde96bf4b5909b04310edb2da Mon Sep 17 00:00:00 2001 From: takahirom Date: Mon, 10 Jul 2023 09:53:51 +0900 Subject: [PATCH 3/4] Add tests --- .../roborazzi/RoborazziGradleProject.kt | 5 ++ .../roborazzi/RoborazziGradleProjectTest.kt | 48 ++++++++++--------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProject.kt b/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProject.kt index b479cbc69..28ff2ca6b 100644 --- a/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProject.kt +++ b/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProject.kt @@ -169,6 +169,11 @@ dependencies { } } + fun checkCompareFileExists() { + val recordedFile = testProjectDir.root.resolve("app/build/test-results/roborazzi/compare-report.json") + assert(recordedFile.exists()) + } + fun checkRecordedFileExists(path: String) { val recordedFile = testProjectDir.root.resolve(path) assert(recordedFile.exists()) diff --git a/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProjectTest.kt b/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProjectTest.kt index 9ba526069..ffa1d9387 100644 --- a/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProjectTest.kt +++ b/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProjectTest.kt @@ -8,7 +8,8 @@ class RoborazziGradleProjectTest { @get:Rule val testProjectDir = TemporaryFolder() - private val pathAndName = + + private val screenshotAndName = "app/build/outputs/roborazzi/com.github.takahirom.integration_test_project.RoborazziTest" @Test @@ -16,9 +17,9 @@ class RoborazziGradleProjectTest { RoborazziGradleProject(testProjectDir).apply { record() - checkRecordedFileExists("$pathAndName.testCapture.png") - checkRecordedFileNotExists("$pathAndName.testCapture_compare.png") - checkRecordedFileNotExists("$pathAndName.testCapture_actual.png") + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") } } @@ -29,9 +30,9 @@ class RoborazziGradleProjectTest { // Record task shouldn't be skipped even after unit test recordWithSystemParameter() - checkRecordedFileExists("$pathAndName.testCapture.png") - checkRecordedFileNotExists("$pathAndName.testCapture_compare.png") - checkRecordedFileNotExists("$pathAndName.testCapture_actual.png") + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") } } @@ -42,9 +43,9 @@ class RoborazziGradleProjectTest { // Record task shouldn't be skipped even after unit test record() - checkRecordedFileExists("$pathAndName.testCapture.png") - checkRecordedFileNotExists("$pathAndName.testCapture_compare.png") - checkRecordedFileNotExists("$pathAndName.testCapture_actual.png") + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") } } @@ -55,9 +56,9 @@ class RoborazziGradleProjectTest { changeScreen() verifyAndFail() - checkRecordedFileExists("$pathAndName.testCapture.png") - checkRecordedFileExists("$pathAndName.testCapture_compare.png") - checkRecordedFileExists("$pathAndName.testCapture_actual.png") + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileExists("$screenshotAndName.testCapture_actual.png") } } @@ -68,9 +69,9 @@ class RoborazziGradleProjectTest { record() verify() - checkRecordedFileExists("$pathAndName.testCapture.png") - checkRecordedFileNotExists("$pathAndName.testCapture_compare.png") - checkRecordedFileNotExists("$pathAndName.testCapture_actual.png") + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") } } @@ -81,9 +82,11 @@ class RoborazziGradleProjectTest { changeScreen() compare() - checkRecordedFileExists("$pathAndName.testCapture.png") - checkRecordedFileExists("$pathAndName.testCapture_compare.png") - checkRecordedFileExists("$pathAndName.testCapture_actual.png") + checkCompareFileExists() + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileExists("$screenshotAndName.testCapture_actual.png") } } @@ -93,9 +96,10 @@ class RoborazziGradleProjectTest { record() compare() - checkRecordedFileExists("$pathAndName.testCapture.png") - checkRecordedFileNotExists("$pathAndName.testCapture_compare.png") - checkRecordedFileNotExists("$pathAndName.testCapture_actual.png") + checkCompareFileExists() + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") } } } \ No newline at end of file From 61f20577a40cb8dc8f5444fbbdc1a02073683a4a Mon Sep 17 00:00:00 2001 From: takahirom Date: Mon, 10 Jul 2023 10:09:53 +0900 Subject: [PATCH 4/4] Add tests --- .../roborazzi/RoborazziGradleProject.kt | 40 +++++++++++++++-- .../roborazzi/RoborazziGradleProjectTest.kt | 44 +++++++++++++++++++ 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProject.kt b/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProject.kt index 28ff2ca6b..7e2f20e1f 100644 --- a/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProject.kt +++ b/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProject.kt @@ -35,6 +35,17 @@ class RoborazziGradleProject(val testProjectDir: TemporaryFolder) { return runTask(task, BuildType.BuildAndFail) } + fun verifyAndRecord(): BuildResult { + val task = "verifyAndRecordRoborazziDebug" + return runTask(task) + } + + fun verifyAndRecordAndFail(): BuildResult { + val task = "verifyAndRecordRoborazziDebug" + return runTask(task, BuildType.BuildAndFail) + } + + fun compare(): BuildResult { val task = "compareRoborazziDebug" return runTask(task) @@ -169,19 +180,40 @@ dependencies { } } + fun checkCompareFileNotExists() { + val recordedFile = + testProjectDir.root.resolve("app/build/test-results/roborazzi/compare-report.json") + assert(!recordedFile.exists()) { + "File exists: ${recordedFile.absolutePath}" + } + } + fun checkCompareFileExists() { - val recordedFile = testProjectDir.root.resolve("app/build/test-results/roborazzi/compare-report.json") - assert(recordedFile.exists()) + val recordedFile = + testProjectDir.root.resolve("app/build/test-results/roborazzi/compare-report.json") + assert(recordedFile.exists()) { + "File not exists: ${recordedFile.absolutePath}" + } } fun checkRecordedFileExists(path: String) { val recordedFile = testProjectDir.root.resolve(path) - assert(recordedFile.exists()) + assert(recordedFile.exists()) { + "File not exists: $path" + } + } + + fun getFileHash(path: String): Int { + val recordedFile = testProjectDir.root.resolve(path) + return recordedFile.readBytes().contentHashCode() } + fun checkRecordedFileNotExists(path: String) { val recordedFile = testProjectDir.root.resolve(path) - assert(!recordedFile.exists()) + assert(!recordedFile.exists()) { + "File exists: $path" + } } fun changeScreen() { diff --git a/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProjectTest.kt b/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProjectTest.kt index ffa1d9387..ad8d4eefc 100644 --- a/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProjectTest.kt +++ b/include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/RoborazziGradleProjectTest.kt @@ -1,5 +1,7 @@ package io.github.takahirom.roborazzi +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder @@ -17,6 +19,7 @@ class RoborazziGradleProjectTest { RoborazziGradleProject(testProjectDir).apply { record() + checkCompareFileNotExists() checkRecordedFileExists("$screenshotAndName.testCapture.png") checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") @@ -30,6 +33,7 @@ class RoborazziGradleProjectTest { // Record task shouldn't be skipped even after unit test recordWithSystemParameter() + checkCompareFileNotExists() checkRecordedFileExists("$screenshotAndName.testCapture.png") checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") @@ -43,6 +47,7 @@ class RoborazziGradleProjectTest { // Record task shouldn't be skipped even after unit test record() + checkCompareFileNotExists() checkRecordedFileExists("$screenshotAndName.testCapture.png") checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") @@ -54,8 +59,13 @@ class RoborazziGradleProjectTest { RoborazziGradleProject(testProjectDir).apply { record() changeScreen() + val recordFileHash1 = getFileHash("$screenshotAndName.testCapture.png") + verifyAndFail() + val recordFileHash2 = getFileHash("$screenshotAndName.testCapture.png") + assertEquals(recordFileHash1, recordFileHash2) + checkCompareFileNotExists() checkRecordedFileExists("$screenshotAndName.testCapture.png") checkRecordedFileExists("$screenshotAndName.testCapture_compare.png") checkRecordedFileExists("$screenshotAndName.testCapture_actual.png") @@ -69,6 +79,40 @@ class RoborazziGradleProjectTest { record() verify() + checkCompareFileNotExists() + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") + } + } + + + @Test + fun verifyAndRecord_changeDetect() { + RoborazziGradleProject(testProjectDir).apply { + record() + val recordFileHash1 = getFileHash("$screenshotAndName.testCapture.png") + changeScreen() + + verifyAndRecordAndFail() + + val recordFileHash2 = getFileHash("$screenshotAndName.testCapture.png") + assertNotEquals(recordFileHash1, recordFileHash2) + checkCompareFileNotExists() + checkRecordedFileExists("$screenshotAndName.testCapture.png") + checkRecordedFileExists("$screenshotAndName.testCapture_compare.png") + checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png") + } + } + + + @Test + fun verifyAndRecord_nochange() { + RoborazziGradleProject(testProjectDir).apply { + record() + verifyAndRecord() + + checkCompareFileNotExists() checkRecordedFileExists("$screenshotAndName.testCapture.png") checkRecordedFileNotExists("$screenshotAndName.testCapture_compare.png") checkRecordedFileNotExists("$screenshotAndName.testCapture_actual.png")