https://github.com/diffplug/selfie
Snapshot testing for Java, Kotlin, and the JVM
https://github.com/diffplug/selfie
groovy java jvm kotlin scala snapshot snapshot-testing snapshot-tests
Last synced: 4 days ago
JSON representation
Snapshot testing for Java, Kotlin, and the JVM
- Host: GitHub
- URL: https://github.com/diffplug/selfie
- Owner: diffplug
- License: apache-2.0
- Created: 2023-03-21T00:41:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-01T20:45:18.000Z (12 months ago)
- Last Synced: 2024-05-01T20:50:16.862Z (12 months ago)
- Topics: groovy, java, jvm, kotlin, scala, snapshot, snapshot-testing, snapshot-tests
- Language: Kotlin
- Homepage: https://selfie.dev
- Size: 7.73 MB
- Stars: 35
- Watchers: 3
- Forks: 7
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-java - Selfie
README
# Selfie: snapshot testing and memoizing for Python, JVM, and [(your PR here)](https://github.com/diffplug/selfie/issues/85)

## Key features
- Just add a test dependency ([py](https://selfie.dev/py/get-started#installation), [jvm](https://selfie.dev/jvm/get-started#installation)), zero setup, zero config.
- Snapshots can be [inline literals](https://selfie.dev/py#literal) or [on disk](https://selfie.dev/py#like-a-filesystem).
- Use `expect_selfie` for testing or `cache_selfie` for [memoizing expensive API calls](https://selfie.dev/py/cache).
- Disk snapshots are automatically [garbage collected](https://github.com/diffplug/selfie/blob/main/jvm/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/junit5/SelfieGC.kt) when the test class or test method is removed.
- Snapshots are **just strings**. Use html, json, markdown, whatever. No [magic serializers](https://selfie.dev/py/cache#roundtripping-typed-data).
- Record **multiple facets** of the entity under test, e.g. for a web request...
- store the HTML as one facet
- store HTML-rendered-to-markdown as another facet
- store cookies in another facet
- **assert some facets on disk, others inline**
- see gif above for live demo, detailed example [here](https://selfie.dev/py/facets#harmonizing-disk-and-inline-literals)Python and JVM ports are both production-ready, other platforms on the way: [js](https://github.com/diffplug/selfie/issues/84), [.NET, go, ...](https://github.com/diffplug/selfie/issues/85)
## Documentation
- Quickstart **([py](https://selfie.dev/py/get-started#quickstart), [jvm](https://selfie.dev/jvm/get-started#quickstart))**
- Facets **([py](https://selfie.dev/py/facets), [jvm](https://selfie.dev/jvm/facets))**
- Caching / memoizing **([py](https://selfie.dev/py/cache), [jvm](https://selfie.dev/jvm/cache))**
- Why selfie **([py](https://selfie.dev/py), [jvm](https://selfie.dev/jvm))**
- API reference **([py](https://pydoc.selfie.dev/namespacemembers_func), [jvm](https://kdoc.selfie.dev/))**## Contributing
PRs welcome! Horror stories and glory stories too, share your experience! See [`CONTRIBUTING.md`](CONTRIBUTING.md).
## Acknowledgements
Heavily inspired by [origin-energy's java-snapshot-testing](https://github.com/origin-energy/java-snapshot-testing), which in turn is heavily inspired by [Facebook's jest-snapshot](https://jestjs.io/docs/snapshot-testing).