Skip to content

Releases: approvals/ApprovalTests.Java

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)

XmlXomApprovals

07 Oct 18:02
Compare
Choose a tag to compare

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>😸 &amp; 🐶</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

30 Sep 18:03
Compare
Choose a tag to compare

Araxis Merge Reporter for MacOS #172
JsonJacksonApprovals now accepts an ObjectMapper #478

Minor fixes

23 Sep 17:49
1f86820
Compare
Choose a tag to compare

What's Changed

  • #554 new constructor for MultiScrubber(Collection<Scrubber> scrubbers)
  • #551 verifyJson to adhere to passed GsonBuilder while pretty printing
  • Better error/help message for ApprovalsDuplicateVerifyException

Saver2 utilities

16 Sep 17:53
Compare
Choose a tag to compare

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

12 Aug 17:45
dddfa87
Compare
Choose a tag to compare

See #520

See the documentation here.

Thanks to @FWest98 for this contribution!

Minor Improvements to JsonApprovals

11 Jul 21:24
Compare
Choose a tag to compare

Fixes for
#531 verifyAsJson() handles null LocalTimeDates.
#479 verifyJson() accepts GsonBuilder

InlineOptions.semiAutomaticWithPreviousApproved()

20 May 17:20
Compare
Choose a tag to compare