Releases: approvals/ApprovalTests.Java
Bugfixes for loadWebPage and readBufferedStream
Use UrlConnection in NetUtils instead of Apache HttpClient
As first fix to #607 let's use java's built-in functionality to make web requests.
DateScrubber & Approve-All Script
Support more date formats in DateScrubber
, see Documentation
Approval-All Script
All failed approvals are now logged in .approval_tests_temp/.failed_comparison.log
. There will be also a script generated that will approve all failed tests.
Script assumes it is being run from the .approval_tests_temp directory.
on Unix
cd .approval_tests_temp
./approve_all.sh
on Windows
cd .approval_tests_temp
./approve_all.bat
Support for more date formats when using DateScrubber
DateScrubber
now detects dates formatted like 2024-12-17
or 2024-12-18T14:04:46.746130Z
.
ReporterThatCreatesApprovalScript
For Windows and Linux!
When this reporter is used it creates a script that, when it runs, will approve all failed tests.
The script file will be either
.approval_tests_temp\approval_script.bat
or
.approval_tests_temp/approval_script.sh
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);