diff --git a/README.md b/README.md index a7c0c0c..11a55fb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +## Snapshot Testing for [JUnit](https://junit.org/) & [Spock](http://spockframework.org/) + #### Purpose of Snapshot Testing Snapshots help figuring out whether the output of the modules covered by tests is changed, without doing tons of asserts! @@ -16,8 +18,6 @@ Based on [facebook's Jest framework](https://facebook.github.io/jest/docs/en/sna - - #### How to install using [Maven](https://mvnrepository.com/artifact/io.github.json-snapshot/json-snapshot/1.0.17) @@ -33,7 +33,7 @@ Add to your pom.xml dependencies section: ``` -#### Usage +#### Usage (JUnit) ```java package com.example; @@ -188,6 +188,49 @@ com.example.ExampleTest.shouldExtractArgsFromFakeMethodWithComplexObject=[ Whenever it runs again, the `expect` method argument will be automatically validated with the `.snap` file. That is why you should commit every `.snap` file created. +#### Usage (Spock) + +```groovy +package specs + +import static io.github.jsonSnapshot.SnapshotMatcher.expectScenario +import io.github.jsonSnapshot.SnapshotMatcher +import io.github.jsonSnapshot.SpockConfig +import spock.lang.Specification + +class MySpec extends Specification { + + def cleanupSpec() { + SnapshotMatcher.validateSnapshots() + } + + def setupSpec() { + SnapshotMatcher.start(new SpockConfig()) + } + + def 'Convert #scenario to uppercase'() { + + when: 'I convert to uppercase' + def result = MyUtility.toUpperCase(value) + + then: 'Should convert letters to uppercase' + expectScenario(scenario, uppercase).toMatchSnapshot() + + where: + scenario | value + 'letter' | 'a' + 'number' | '1' + } +} +``` + +#### Parameterized testing + +In order to support parameterized testing you can use the `expectScenario` method that accepts a scenario as the first parameter. + +`expectScenario(scenario, object).toMatchSnapshot()` + +You need to ensure all your scenarios are unique within a single method. You will normally pass a combination of your parameters to achieve this. #### Inheritance @@ -199,6 +242,7 @@ Start SnapshotMatcher on child classes only: ```java package com.example; + import org.junit.AfterClass; import org.junit.BeforeClass; diff --git a/pom.xml b/pom.xml index b916558..1e872c8 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.github.json-snapshot json-snapshot - 1.0.17 + 1.3.0 jar json-snapshot @@ -81,6 +81,11 @@ junit-jupiter-engine 5.3.2 + + org.junit.jupiter + junit-jupiter-params + 5.3.2 + org.mockito mockito-junit-jupiter @@ -115,6 +120,22 @@ + + + org.apache.maven.plugins + maven-shade-plugin + 2.3 + + + + package + + shade + + + + + com.diffplug.spotless spotless-maven-plugin @@ -224,4 +245,4 @@ - \ No newline at end of file + diff --git a/src/main/java/io/github/jsonSnapshot/DefaultConfig.java b/src/main/java/io/github/jsonSnapshot/DefaultConfig.java index cf71b28..737154d 100644 --- a/src/main/java/io/github/jsonSnapshot/DefaultConfig.java +++ b/src/main/java/io/github/jsonSnapshot/DefaultConfig.java @@ -1,7 +1,4 @@ package io.github.jsonSnapshot; -import lombok.Getter; - -public class DefaultConfig implements SnapshotConfig { - @Getter private String filePath = "src/test/java/"; -} +/** Alias for JUnitConfig for Backward Compatibility */ +public class DefaultConfig extends JUnitConfig {} diff --git a/src/main/java/io/github/jsonSnapshot/JUnitConfig.java b/src/main/java/io/github/jsonSnapshot/JUnitConfig.java new file mode 100644 index 0000000..03cbb54 --- /dev/null +++ b/src/main/java/io/github/jsonSnapshot/JUnitConfig.java @@ -0,0 +1,60 @@ +package io.github.jsonSnapshot; + +import java.lang.reflect.Method; +import java.util.stream.Stream; + +import lombok.Getter; + +public class JUnitConfig implements SnapshotConfig { + @Getter private String filePath = "src/test/java/"; + + @Override + public StackTraceElement findStacktraceElement() { + StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); + int elementsToSkip = 1; // Start after stackTrace + while (SnapshotMatcher.class + .getName() + .equals(stackTraceElements[elementsToSkip].getClassName())) { + elementsToSkip++; + } + + return Stream.of(stackTraceElements) + .skip(elementsToSkip) + .filter( + stackTraceElement -> + hasTestAnnotation( + SnapshotMatcher.getMethod( + getClassForName(stackTraceElement.getClassName()), + stackTraceElement.getMethodName()))) + .findFirst() + .orElseThrow( + () -> + new SnapshotMatchException( + "Could not locate a method with one of supported test annotations")); + } + + @Override + public boolean shouldUpdateSnapshot() { + String value = System.getProperty(UPDATE_SNAPSHOTS_PARAMETER); + return value != null && value.toUpperCase().startsWith("T"); + } + + protected boolean hasTestAnnotation(Method method) { + return + // Junit 4 + method.isAnnotationPresent(org.junit.Test.class) + || method.isAnnotationPresent(org.junit.BeforeClass.class) + // JUnit 5 + || method.isAnnotationPresent(org.junit.jupiter.params.ParameterizedTest.class) + || method.isAnnotationPresent(org.junit.jupiter.api.Test.class) + || method.isAnnotationPresent(org.junit.jupiter.api.BeforeAll.class); + } + + private Class getClassForName(String className) { + try { + return Class.forName(className); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/src/main/java/io/github/jsonSnapshot/Snapshot.java b/src/main/java/io/github/jsonSnapshot/Snapshot.java index 9d73e9a..332add5 100644 --- a/src/main/java/io/github/jsonSnapshot/Snapshot.java +++ b/src/main/java/io/github/jsonSnapshot/Snapshot.java @@ -6,6 +6,7 @@ import java.util.Set; import java.util.function.Function; +import org.apache.commons.lang3.StringUtils; import org.assertj.core.util.diff.DiffUtils; import org.assertj.core.util.diff.Patch; @@ -17,20 +18,28 @@ public class Snapshot { private Method method; + private String scenario; + private Function jsonFunction; private Object[] current; + private final SnapshotConfig snapshotConfig; + Snapshot( + SnapshotConfig snapshotConfig, SnapshotFile snapshotFile, Class clazz, Method method, + String scenario, Function jsonFunction, Object... current) { + this.snapshotConfig = snapshotConfig; this.current = current; this.snapshotFile = snapshotFile; this.clazz = clazz; this.method = method; + this.scenario = scenario; this.jsonFunction = jsonFunction; } @@ -43,7 +52,7 @@ public void toMatchSnapshot() { String currentObject = takeSnapshot(); // Match Snapshot - if (rawSnapshot != null) { + if (rawSnapshot != null && !snapshotConfig.shouldUpdateSnapshot()) { if (!rawSnapshot.trim().equals(currentObject.trim())) { throw generateDiffError(rawSnapshot, currentObject); } @@ -88,6 +97,7 @@ private String takeSnapshot() { } public String getSnapshotName() { - return clazz.getName() + "." + method.getName() + "="; + String scenarioFormat = StringUtils.isBlank(scenario) ? "" : "[" + scenario + "]"; + return clazz.getName() + "." + method.getName() + scenarioFormat + "="; } } diff --git a/src/main/java/io/github/jsonSnapshot/SnapshotConfig.java b/src/main/java/io/github/jsonSnapshot/SnapshotConfig.java index f16c811..100a317 100644 --- a/src/main/java/io/github/jsonSnapshot/SnapshotConfig.java +++ b/src/main/java/io/github/jsonSnapshot/SnapshotConfig.java @@ -1,5 +1,11 @@ package io.github.jsonSnapshot; public interface SnapshotConfig { + String UPDATE_SNAPSHOTS_PARAMETER = "update-snapshots"; + String getFilePath(); + + StackTraceElement findStacktraceElement(); + + boolean shouldUpdateSnapshot(); } diff --git a/src/main/java/io/github/jsonSnapshot/SnapshotFile.java b/src/main/java/io/github/jsonSnapshot/SnapshotFile.java index 2303c3f..0414dd6 100644 --- a/src/main/java/io/github/jsonSnapshot/SnapshotFile.java +++ b/src/main/java/io/github/jsonSnapshot/SnapshotFile.java @@ -1,6 +1,10 @@ package io.github.jsonSnapshot; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; diff --git a/src/main/java/io/github/jsonSnapshot/SnapshotMatcher.java b/src/main/java/io/github/jsonSnapshot/SnapshotMatcher.java index 57ed01f..e05aa27 100644 --- a/src/main/java/io/github/jsonSnapshot/SnapshotMatcher.java +++ b/src/main/java/io/github/jsonSnapshot/SnapshotMatcher.java @@ -1,5 +1,7 @@ package io.github.jsonSnapshot; +import static org.assertj.core.util.Arrays.isNullOrEmpty; + import java.io.IOException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -12,10 +14,6 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; -import org.assertj.core.util.Arrays; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.jupiter.api.BeforeAll; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,6 +35,7 @@ public class SnapshotMatcher { private static SnapshotFile snapshotFile = null; private static List calledSnapshots = new ArrayList<>(); private static Function jsonFunction; + private static SnapshotConfig config; public static void start() { start(new DefaultConfig(), defaultJsonFunction()); @@ -52,8 +51,9 @@ public static void start(Function jsonFunction) { public static void start(SnapshotConfig config, Function jsonFunction) { SnapshotMatcher.jsonFunction = jsonFunction; + SnapshotMatcher.config = config; try { - StackTraceElement stackElement = findStackElement(); + StackTraceElement stackElement = config.findStacktraceElement(); clazz = Class.forName(stackElement.getClassName()); snapshotFile = new SnapshotFile( @@ -88,16 +88,31 @@ public static void validateSnapshots() { } } + public static Snapshot expectScenario(String scenario, Object firstObject, Object... others) { + return expectCondition(scenario, firstObject, others); + } + public static Snapshot expect(Object firstObject, Object... others) { + return expectCondition(null, firstObject, others); + } + + /** + * @param scenario for parameterized tests supply a unique scenario for each iteration + * @param firstObject + * @param others + * @return + */ + private static Snapshot expectCondition(String scenario, Object firstObject, Object... others) { if (clazz == null) { throw new SnapshotMatchException( "SnapshotTester not yet started! Start it on @BeforeClass/@BeforeAll with SnapshotMatcher.start()"); } Object[] objects = mergeObjects(firstObject, others); - StackTraceElement stackElement = findStackElement(); + StackTraceElement stackElement = config.findStacktraceElement(); Method method = getMethod(clazz, stackElement.getMethodName()); - Snapshot snapshot = new Snapshot(snapshotFile, clazz, method, jsonFunction, objects); + Snapshot snapshot = + new Snapshot(config, snapshotFile, clazz, method, scenario, jsonFunction, objects); validateExpectCall(snapshot); calledSnapshots.add(snapshot); return snapshot; @@ -160,7 +175,7 @@ private static void validateExpectCall(Snapshot snapshot) { } } - private static Method getMethod(Class clazz, String methodName) { + public static Method getMethod(Class clazz, String methodName) { try { return Stream.of(clazz.getDeclaredMethods()) .filter(method -> method.getName().equals(methodName)) @@ -180,51 +195,12 @@ private static Method getMethod(Class clazz, String methodName) { } } - private static StackTraceElement findStackElement() { - StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); - int elementsToSkip = 1; // Start after stackTrace - while (SnapshotMatcher.class - .getName() - .equals(stackTraceElements[elementsToSkip].getClassName())) { - elementsToSkip++; - } - - return Stream.of(stackTraceElements) - .skip(elementsToSkip) - .filter( - stackTraceElement -> - hasTestAnnotation( - getMethod( - getClass(stackTraceElement.getClassName()), - stackTraceElement.getMethodName()))) - .findFirst() - .orElseThrow( - () -> - new SnapshotMatchException( - "Could not locate a method with one of supported test annotations")); - } - - private static boolean hasTestAnnotation(Method method) { - return method.isAnnotationPresent(Test.class) - || method.isAnnotationPresent(BeforeClass.class) - || method.isAnnotationPresent(org.junit.jupiter.api.Test.class) - || method.isAnnotationPresent(BeforeAll.class); - } - private static Object[] mergeObjects(Object firstObject, Object[] others) { Object[] objects = new Object[1]; objects[0] = firstObject; - if (!Arrays.isNullOrEmpty(others)) { + if (!isNullOrEmpty(others)) { objects = ArrayUtils.addAll(objects, others); } return objects; } - - private static Class getClass(String className) { - try { - return Class.forName(className); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException(e); - } - } } diff --git a/src/main/java/io/github/jsonSnapshot/SpockConfig.java b/src/main/java/io/github/jsonSnapshot/SpockConfig.java new file mode 100644 index 0000000..1c738bb --- /dev/null +++ b/src/main/java/io/github/jsonSnapshot/SpockConfig.java @@ -0,0 +1,35 @@ +package io.github.jsonSnapshot; + +import java.util.Arrays; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** For use by Spock http://spockframework.org/ */ +@RequiredArgsConstructor +public class SpockConfig implements SnapshotConfig { + + /** + * In order to locate the correct test method in the stacktrace the base package of the specs need + * to be supplied. + */ + private final String specBasePackage; + + @Getter private String filePath = "src/test/groovy/"; + + @Override + public StackTraceElement findStacktraceElement() { + StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); + return Arrays.stream(stackTraceElements) + .filter(it -> it.getClassName().startsWith(specBasePackage)) + .findFirst() + .orElseThrow( + () -> new SnapshotMatchException("Could not locate a method in package 'spec'")); + } + + @Override + public boolean shouldUpdateSnapshot() { + String value = System.getProperty(UPDATE_SNAPSHOTS_PARAMETER); + return value != null && value.toUpperCase().startsWith("T"); + } +} diff --git a/src/test/java/io/github/jsonSnapshot/JunitConfigTest.java b/src/test/java/io/github/jsonSnapshot/JunitConfigTest.java new file mode 100644 index 0000000..35b5fe9 --- /dev/null +++ b/src/test/java/io/github/jsonSnapshot/JunitConfigTest.java @@ -0,0 +1,34 @@ +package io.github.jsonSnapshot; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +public class JunitConfigTest { + + @AfterEach + public void beforeEach() { + System.setProperty(SnapshotConfig.UPDATE_SNAPSHOTS_PARAMETER, ""); + } + + @Test + public void shouldNotUpdateSnapshotNotPassed() { + SnapshotConfig snapshotConfig = new JUnitConfig(); + assertThat(snapshotConfig.shouldUpdateSnapshot()).isFalse(); + } + + @Test + public void shouldUpdateSnapshotTrue() { + System.setProperty(SnapshotConfig.UPDATE_SNAPSHOTS_PARAMETER, "true"); + SnapshotConfig snapshotConfig = new JUnitConfig(); + assertThat(snapshotConfig.shouldUpdateSnapshot()).isTrue(); + } + + @Test + public void shouldUpdateSnapshotFalse() { + System.setProperty(SnapshotConfig.UPDATE_SNAPSHOTS_PARAMETER, "false"); + SnapshotConfig snapshotConfig = new JUnitConfig(); + assertThat(snapshotConfig.shouldUpdateSnapshot()).isFalse(); + } +} diff --git a/src/test/java/io/github/jsonSnapshot/SnapshotIntegrationTest.snap b/src/test/java/io/github/jsonSnapshot/SnapshotIntegrationTest.snap index 1887a15..820dc28 100644 --- a/src/test/java/io/github/jsonSnapshot/SnapshotIntegrationTest.snap +++ b/src/test/java/io/github/jsonSnapshot/SnapshotIntegrationTest.snap @@ -49,4 +49,13 @@ io.github.jsonSnapshot.SnapshotIntegrationTest.shouldThrowSnapshotMatchException "value": 5, "name": "anyName5" } +] + + +io.github.jsonSnapshot.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=[ + { + "id": "anyId5", + "value": 6, + "name": "anyName5" + } ] \ No newline at end of file diff --git a/src/test/java/io/github/jsonSnapshot/SnapshotMatcherScenarioTest.java b/src/test/java/io/github/jsonSnapshot/SnapshotMatcherScenarioTest.java new file mode 100644 index 0000000..44adf48 --- /dev/null +++ b/src/test/java/io/github/jsonSnapshot/SnapshotMatcherScenarioTest.java @@ -0,0 +1,65 @@ +package io.github.jsonSnapshot; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class SnapshotMatcherScenarioTest { + + private static final String FILE_PATH = + "src/test/java/io/github/jsonSnapshot/SnapshotMatcherScenarioTest.snap"; + + @BeforeAll + static void beforeAll() { + SnapshotMatcher.start(); + } + + @AfterAll + static void afterAll() throws IOException { + SnapshotMatcher.validateSnapshots(); + File f = new File(FILE_PATH); + assertThat(StringUtils.join(Files.readAllLines(f.toPath()), "\n")) + .isEqualTo( + "io.github.jsonSnapshot.SnapshotMatcherScenarioTest.should1ShowSnapshotSuccessfully[Scenario A]=[\n" + + " \"any type of object\"\n" + + "]\n\n\n" + + "io.github.jsonSnapshot.SnapshotMatcherScenarioTest.should2SecondSnapshotExecutionSuccessfully[Scenario B]=[\n" + + " \"any second type of object\",\n" + + " \"any third type of object\"\n" + + "]"); + Files.delete(Paths.get(FILE_PATH)); + } + + @Test + void should1ShowSnapshotSuccessfully() throws IOException { + + File f = new File(FILE_PATH); + if (!f.exists() || f.isDirectory()) { + throw new RuntimeException("File should exist here"); + } + SnapshotMatcher.expectScenario("Scenario A", "any type of object").toMatchSnapshot(); + } + + @Test + void should2SecondSnapshotExecutionSuccessfully() throws IOException { + + File f = new File(FILE_PATH); + if (!f.exists() || f.isDirectory()) { + throw new RuntimeException("File should exist here"); + } + SnapshotMatcher.expectScenario( + "Scenario B", "any second type of object", "any third type of object") + .toMatchSnapshot(); + } +} diff --git a/src/test/java/io/github/jsonSnapshot/SnapshotTest.java b/src/test/java/io/github/jsonSnapshot/SnapshotTest.java index 4dc3e26..2e61128 100644 --- a/src/test/java/io/github/jsonSnapshot/SnapshotTest.java +++ b/src/test/java/io/github/jsonSnapshot/SnapshotTest.java @@ -6,14 +6,19 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.HashSet; +import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; +import lombok.SneakyThrows; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) @@ -33,9 +38,11 @@ void setUp() throws NoSuchMethodException, IOException { snapshotFile = new SnapshotFile(DEFAULT_CONFIG.getFilePath(), "anyFilePath"); snapshot = new Snapshot( + new DefaultConfig(), snapshotFile, String.class, String.class.getDeclaredMethod("toString"), + null, SnapshotMatcher.defaultJsonFunction(), "anyObject"); } @@ -64,4 +71,59 @@ void shouldMatchSnapshotWithException() { assertThrows(SnapshotMatchException.class, snapshot::toMatchSnapshot); } + + @SneakyThrows + @Test + void shouldRenderScenarioNameWhenSupplied() { + Snapshot snapshotWithScenario = + new Snapshot( + new DefaultConfig(), + snapshotFile, + String.class, + String.class.getDeclaredMethod("toString"), + "hello world", + SnapshotMatcher.defaultJsonFunction(), + "anyObject"); + assertThat(snapshotWithScenario.getSnapshotName()) + .isEqualTo("java.lang.String.toString[hello world]="); + } + + @SneakyThrows + @Test + void shouldNotRenderScenarioNameWhenNull() { + Snapshot snapshotWithoutScenario = + new Snapshot( + new DefaultConfig(), + snapshotFile, + String.class, + String.class.getDeclaredMethod("toString"), + null, + SnapshotMatcher.defaultJsonFunction(), + "anyObject"); + assertThat(snapshotWithoutScenario.getSnapshotName()).isEqualTo("java.lang.String.toString="); + } + + @SneakyThrows + @Test + void shouldOverwriteSnapshotsWhenParamIsPassed() { + SnapshotConfig mockConfig = Mockito.mock(SnapshotConfig.class); + Mockito.when(mockConfig.shouldUpdateSnapshot()).thenReturn(true); + SnapshotFile snapshotFile = Mockito.mock(SnapshotFile.class); + Set set = new HashSet<>(); + set.add("java.lang.String.toString[hello world]=[{" + "\"a\": \"b\"" + "}]"); + Mockito.when(snapshotFile.getRawSnapshots()).thenReturn(set); + + Snapshot snapshot = + new Snapshot( + mockConfig, + snapshotFile, + String.class, + String.class.getDeclaredMethod("toString"), + "hello world", + SnapshotMatcher.defaultJsonFunction(), + "anyObject"); + snapshot.toMatchSnapshot(); + Mockito.verify(snapshotFile) + .push("java.lang.String.toString[hello world]=[\n" + " \"anyObject\"\n" + "]"); + } } diff --git a/src/test/java/io/github/jsonSnapshot/SpockConfigTest.java b/src/test/java/io/github/jsonSnapshot/SpockConfigTest.java new file mode 100644 index 0000000..9bda70b --- /dev/null +++ b/src/test/java/io/github/jsonSnapshot/SpockConfigTest.java @@ -0,0 +1,34 @@ +package io.github.jsonSnapshot; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +public class SpockConfigTest { + + @AfterEach + public void beforeEach() { + System.setProperty(SnapshotConfig.UPDATE_SNAPSHOTS_PARAMETER, ""); + } + + @Test + public void shouldNotUpdateSnapshotNotPassed() { + SnapshotConfig snapshotConfig = new SpockConfig("spec"); + assertThat(snapshotConfig.shouldUpdateSnapshot()).isFalse(); + } + + @Test + public void shouldUpdateSnapshotTrue() { + System.setProperty(SnapshotConfig.UPDATE_SNAPSHOTS_PARAMETER, "true"); + SnapshotConfig snapshotConfig = new SpockConfig("spec"); + assertThat(snapshotConfig.shouldUpdateSnapshot()).isTrue(); + } + + @Test + public void shouldUpdateSnapshotFalse() { + System.setProperty(SnapshotConfig.UPDATE_SNAPSHOTS_PARAMETER, "false"); + SnapshotConfig snapshotConfig = new SpockConfig("spec"); + assertThat(snapshotConfig.shouldUpdateSnapshot()).isFalse(); + } +}