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 11
11
import java .nio .file .Paths ;
12
12
import java .util .ArrayList ;
13
13
import java .util .List ;
14
+ import java .util .Optional ;
14
15
import java .util .stream .Collectors ;
15
16
import java .util .stream .Stream ;
16
17
@@ -48,11 +49,14 @@ public boolean matchesSafely(T o) {
48
49
if (Files .exists (snapshotPath )) {
49
50
// File exists => Compare snapshot file to given object
50
51
return compareSnapshot (o , snapshotPath );
51
- } else {
52
+ } else if ( isWriteSnapshotActivated ()) {
52
53
// File doesn't exist => Create snapshot file and return true
53
54
createSnapshot (o , snapshotPath );
54
55
return true ;
55
56
}
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 ;
56
60
}
57
61
58
62
/**
@@ -153,4 +157,7 @@ private StackTraceElement getCaller() {
153
157
.orElse (null );
154
158
}
155
159
160
+ private boolean isWriteSnapshotActivated () {
161
+ return System .getProperty ("test.snapshots.write" ) != null ;
162
+ }
156
163
}
You can’t perform that action at this time.
0 commit comments