Open mbechto opened 2 weeks ago
hello, I think we have exactly what you are looking for. You'd want to use a different Reporter. Iirc the class name would be AutoApproveReporter
. You can apply that either
@UseReporter(AutoApproveReporter.class)
, Options
, Approvals.verify(actual, new Options().withReporter(new AutoApproveReporter())
, export APPROVAL_TESTS_USE_REPORTER=AutoApproveReporter
and then mvn verify
. The -D
won't work as env variables are different from system properties and we don't have support for that (yet).Replying from iPad here currently, I'll have a proper look later and will update my comment where I didn't remember the syntax correctly anymore.
Lars
Updated my answer, let me know if there are still issues or if it's not quite what you have in mind.
Grüße aus Estland ;)
PS: oddly enough, the 2nd options with Options
wont even report that a test failed, it approves the file and mrks the test as passing, the other 2 options dont. Guess that is something we explore the next time @isidore and I work together (beginning of December). So let's not close this issue yet, even if it's answered and maybe solves your problem.
I guess that works, thanks for the insightful response @LarsEckart! 🙂
Hi,
I am using ApprovalTests.Java for a while now and was wondering whether you would be open to a feature request (or tell me how I can improve my development workflow).
Having done some Rust recently, I am used to the cargo-insta snapshot testing library. One thing I like about insta is, that it displays the diff directly in the terminal where cargo build is executed and you are presented with the option to accept or reject the changes with a key-press (y/n).
With ApprovalTests the diff view - in my case in IntelliJ - opens, which is fine in most cases. But with an increasing number of changed files and diffs, this causes a cascade of many diff windows during each change.
It may be just how I like to do it, but in my daily workflow I like to review all changes in git before I commit. So to me, clicking all those diff windows feels tedious - where I would just press "y" in insta.
I thought about automating this process by scripting it, something along the lines of
for f in *.received.* ; do mv "$f" "${f/.received/.approved}"; done
but this feels a little awkward.Proposal: Add a convenience feature to accept all changes automatically.
Implementation idea: A system property e.g. provided at build time:
or environment variable
that causes ApprovalTests to override the
*.approved.*
files with their changes without prompting.