From 8dd6797614df167b27b4b0c45b9f4b029ec55b57 Mon Sep 17 00:00:00 2001 From: Shicong Huang Date: Tue, 9 Jul 2019 10:49:20 -0400 Subject: [PATCH] Read golden images from src directly (#159) This PR prevents Gradle from copying the golden images to build/resources/test, so the screenshot test would read golden images from src/test/resources directly and display the path in test log if the test fails. Because the path pointing to the actual file in src/ folder, the engineer can easily find it. --- core/build.gradle | 6 ++++++ .../google/registry/webdriver/RepeatableRunner.java | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/build.gradle b/core/build.gradle index 4fb98c5f8..d267571f6 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -97,6 +97,10 @@ sourceSets { } } +processTestResources { + exclude '**/webdriver/*' +} + configurations { css jaxb @@ -140,6 +144,8 @@ dependencies { "${rootDir}/third_party/objectify/v4_1/objectify-4.1.3.jar") testImplementation project(':third_party') + testRuntime files(sourceSets.test.resources.srcDirs) + compile deps['com.beust:jcommander'] compile deps['com.google.api-client:google-api-client'] maybeRuntime deps['com.google.api-client:google-api-client-appengine'] diff --git a/core/src/test/java/google/registry/webdriver/RepeatableRunner.java b/core/src/test/java/google/registry/webdriver/RepeatableRunner.java index 36c9feb8d..39b0f7c84 100644 --- a/core/src/test/java/google/registry/webdriver/RepeatableRunner.java +++ b/core/src/test/java/google/registry/webdriver/RepeatableRunner.java @@ -141,7 +141,15 @@ public class RepeatableRunner extends BlockJUnit4ClassRunner { int numSuccess = 0, numFailure = 0; Throwable lastException = null; for (int attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) { - attemptNumber.set(attempt); + // attemptNumber would be null if any exception happens during the + // instantiation of test class object(including test rules). However, + // those exceptions would not be actually thrown until statement.evaluate() + // is invoked. So, we should just skip the setter and let the statement + // be evaluated. Then we should be able to find the stack trace of + // root cause in the test reports. + if (attemptNumber != null) { + attemptNumber.set(attempt); + } try { statement.evaluate(); numSuccess++;