Releases: approvals/ApprovalTests.Java
Allow configuration of project base directory
By default, Approvals uses the working directory to find the working directory and its children to find source file and store received and approved files. This is now configurable if your working directory no longer contains the source. You can do this by setting either the system property or system environment variable called APPROVALTESTS_PROJECT_DIRECTORY
. Here is an example of doing this when running tests with maven on forks:
<systemPropertyVariables>
<APPROVALTESTS_PROJECT_DIRECTORY>${project.basedir}</APPROVALTESTS_PROJECT_DIRECTORY>
</systemPropertyVariables>
Reported in #608
Also fixes #612
Add Once object like in Golang
Once.run(() -> ... your code here ...)
Will execute that code once and only once.
Bugfixes for loadWebPage and readBufferedStream
24.14.2 a reformat code
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)