File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
snapshot-matcher/src/main/java/com/zenika/snapshotmatcher Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1111import java .nio .file .Paths ;
1212import java .util .ArrayList ;
1313import java .util .List ;
14+ import java .util .Optional ;
1415import java .util .stream .Collectors ;
1516import java .util .stream .Stream ;
1617
@@ -48,11 +49,14 @@ public boolean matchesSafely(T o) {
4849 if (Files .exists (snapshotPath )) {
4950 // File exists => Compare snapshot file to given object
5051 return compareSnapshot (o , snapshotPath );
51- } else {
52+ } else if ( isWriteSnapshotActivated ()) {
5253 // File doesn't exist => Create snapshot file and return true
5354 createSnapshot (o , snapshotPath );
5455 return true ;
5556 }
57+ System .out .println ("Snapshot writing is not activated in this environment." );
58+ System .out .println ("Activate snapshot writing by using -Dtest.snapshots.write" );
59+ return false ;
5660 }
5761
5862 /**
@@ -153,4 +157,7 @@ private StackTraceElement getCaller() {
153157 .orElse (null );
154158 }
155159
160+ private boolean isWriteSnapshotActivated () {
161+ return System .getProperty ("test.snapshots.write" ) != null ;
162+ }
156163}
You can’t perform that action at this time.
0 commit comments