New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @Snapshot
as built-in extension
#1873
Add @Snapshot
as built-in extension
#1873
Conversation
leonard84
commented
Jan 25, 2024
- Make Snapshotter production ready
- Group snapshots by class
- Introduce snapshotId for multiple snapshots
- Make normalization configurable
- Document Snapshotter
- Limit snapshotId length
@skuzzle, maybe you want to review this. It is not intended to replace https://github.com/skuzzle/snapshot-tests but to provide a baseline of functionality. |
@Snapshot
as built-in extension
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1873 +/- ##
============================================
+ Coverage 80.44% 80.68% +0.23%
- Complexity 4337 4363 +26
============================================
Files 441 441
Lines 13534 13674 +140
Branches 1707 1717 +10
============================================
+ Hits 10888 11033 +145
+ Misses 2008 2005 -3
+ Partials 638 636 -2 ☔ View full report in Codecov by Sentry. |
748aea0
to
155d263
Compare
I gave this a quick look and I think its pretty cool. The API is way simpler than what I built and yet allows to easily plugin additional functionality. Some considerations and remarks:
|
Thanks for your feedback
I don't see a connection between failing the test and adding the files to the commit. Note: if a snapshot file is missing it will return the string
I can see that, however I don't think failing the test makes it obvious. I think I'll add a note to the documentation that one should re-run the tests after updating the snapshots to validate that they are stable and to be careful of dynamic values in general.
I agree, but I wanted to keep this feature small and not include any additional dependencies. It is also why I designed it to be extensible so that one can easily include better diffing. The other reason is that - at least for local development - the IntelliJ diff view is really helpful and alleviates the need for a full-blown diff in most cases.
Yeah, it is complicated, in Spock some snapshots are only generated/used when the build is run with a specific Groovy or Java version.
Stableness was one reason; the other was to offer the ability to validate that something hadn't changed between an action. |
spock-core/src/main/java/org/spockframework/runtime/extension/builtin/SnapshotConfig.java
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/runtime/extension/builtin/SnapshotConfig.java
Outdated
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/runtime/extension/builtin/SnapshotConfig.java
Outdated
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/runtime/extension/builtin/SnapshotExtension.java
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/runtime/extension/builtin/SnapshotExtension.java
Outdated
Show resolved
Hide resolved
@leonard84 Another nice feature would be, if we add a property to the This would allow to open the actual content in another programm to check the file content, or use an external diff tool to compare and merge the |
e4ba0d4
to
f54e5ab
Compare
I've added the |
Co-authored-by: Andreas Turban <andreas.turban@net-baustelle.de>
89cdf8f
to
471bf72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thank you very much!