Skip to content

Releases: approvals/ApprovalTests.Java

Allow configuration of project base directory

03 Feb 18:37
Compare
Choose a tag to compare

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

30 Jan 22:38
Compare
Choose a tag to compare

Once.run(() -> ... your code here ...)
Will execute that code once and only once.

Bugfixes for loadWebPage and readBufferedStream

16 Jan 22:24
Compare
Choose a tag to compare

Use UrlConnection in NetUtils instead of Apache HttpClient

16 Jan 15:24
Compare
Choose a tag to compare

As first fix to #607 let's use java's built-in functionality to make web requests.

DateScrubber & Approve-All Script

13 Jan 18:54
8f673b3
Compare
Choose a tag to compare

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

06 Jan 15:50
Compare
Choose a tag to compare

DateScrubber now detects dates formatted like 2024-12-17 or 2024-12-18T14:04:46.746130Z.

ReporterThatCreatesApprovalScript

12 Dec 22:55
Compare
Choose a tag to compare

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

09 Dec 18:58
Compare
Choose a tag to compare

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

22 Nov 02:48
Compare
Choose a tag to compare
return Queryable.as(1, 2, 3).firstOrThrow(i -> 2 < i, () -> new RuntimeException("Nothing bigger than 2")

Creates local log of touched approved files

31 Oct 21:29
Compare
Choose a tag to compare

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)