Releases: approvals/ApprovalTests.Java
Added Seam for custom exceptions
If you want to customize what error is thrown (#596) , you can now do the following:
// global
private final Closeable oldGenerator = Approvals.settings().registerErrorGenerator((received, approved) -> new AssertionError("Custom message")))
try (AutoCloseable old = Approvals.settings()
.registerErrorGenerator((received, approved) -> new AssertionError("Custom message")))
{
...
}
Queryable.firstOrThrow
return Queryable.as(1, 2, 3).firstOrThrow(i -> 2 < i, () -> new RuntimeException("Nothing bigger than 2")
Creates local log of touched approved files
Note: you need to add the following to your .gitignore
.approval_tests_temp/
ApprovalTests now create a temp log in .approval_tests_temp/.approved_files.log
after each run that stores all the .approved.
files that were touched.
This enables other tooling to do things such as find abandoned files.
Also, we added :
FileUtils.appendToFile(file, txt)
XmlXomApprovals
Xom has support for emojies, so it can be a confinient way to use for xml that contains emojies.
var expected = """
<?xml version="1.0" encoding="UTF-8"?>
<a>
<b>😸 & 🐶</b>
</a>
""";
String minimizedXml = expected.replaceAll("\n", " ").replace(" ", "");
XmlXomApprovals.verifyXml(minimizedXml, new Options().inline(expected));
We also allow you to create your own pretty printer when using Approvals.verify
.
Or no pretty printing at all, then use
Approvals.verifyXml(xml, x -> x);
AraxisMergeReporter and better Jackson support
Minor fixes
Saver2 utilities
Convinience functions for creating Savers that take 2 parameters:
Saver<Tuple<Customer, String>> mailSaver = Saver2.create(mailServer::sendMessage);
We also believe we made approvlatests again compatible with JDK 8.
Support for setting reporter in environment variables
Minor Improvements to JsonApprovals
InlineOptions.semiAutomaticWithPreviousApproved()
24.2.0 a reformat code