Skip to content

Releases: assertj/assertj

v3.27.2

04 Jan 11:08
Compare
Choose a tag to compare

🐛 Bug Fixes

Core

  • Restore support for null-valued maps when ignoring fields #3723

v3.27.1

01 Jan 18:45
Compare
Choose a tag to compare

🚫 Deprecated

Core

  • Deprecate usingComparatorForFields and remove deprecated assertions from usingComparatorForType documentation #3711
  • Deprecate hasCauseReference(Throwable) from Throwable assertions #3715

🐛 Bug Fixes

Core

  • Fix missing introspection for record accessors #3710
  • Honor assertion description in asString()
  • Avoid InputStream manipulation when mark / reset are supported #3713
  • NPE with custom RecursiveComparisonConfiguration on usingRecursiveFieldByFieldElementComparator #3719

⚡ Improvements

  • Declare license using SPDX identifier #3718

❤️ Contributors

Thanks to all the contributors who worked on this release:

@Bananeweizen @jessicant @nith2001

v3.27.0

19 Dec 17:12
Compare
Choose a tag to compare

🚫 Deprecated

Core

  • Deprecate ClassBasedNavigableIterableAssert and ClassBasedNavigableListAssert #3529

✨ New Features

Core

  • Add actual() to access the object under test #3489
  • Add isCompletedWithValueMatchingWithin to CompletableFuture assertions #3506
  • Add completesExceptionallyWithin to CompletableFuture assertions #3597
  • Add inBinary to CharSequence assertions #3600
  • Support for Assertions.byLessThan(Duration) and Assertions.within(Duration) #3486
  • Add standard representation for CharSequence #3617
  • Add predicate descriptions overloads to anyMatch and noneMatch #3639
  • Add doesNotMatch(Predicate) #3684
  • Add usingEquals accepting a BiPredicate and an optional description to provide a custom comparison in assertions #3678

Guava

  • Add isNotEmpty to Table assertions #3559

🐛 Bug Fixes

Core

  • Recursive assertion hasNoNullFields throws NPE with fields of anonymous and local types #3534
  • Fix incorrect mutation of actualElementsGroupedByHashCode in recursive comparison
  • Recursive comparison ignoringFields not working properly with maps #2988
  • Custom representation ignored when describing expected items not in the actual list #3646
  • hasFieldOrPropertyWithValue swallows exceptions thrown by getters, and reports non-existent property instead #3563
  • satisfies() with nested assertions obscures stack trace #2542
  • Recursive comparison fails if ignored fields are not found in expected #3226

⚡ Improvements

Core

  • Report all failing conditions when using satisfies(allOf(Condition...)) #3537
  • Fix Unicode escapes in inUnicode() Javadoc
  • Show error differences if values were compared with equals in recursive comparison #3209
  • Propagate common basetype for extracting(Function...) #3673
  • Add throwable stacktrace to ShouldNotContainCharSequence
  • Remove unused code and other minor cleanup #3683
  • Simplify comparison strategy isLessThan and isLessThanOrEqualTo in AbstractComparisonStrategy #3694
  • Update AbstractCharSequenceAssert.java reference #3700
  • Include stack trace of internal errors in all/any satisfy assertions

🔨 Dependency Upgrades

Core

  • Upgrade to Byte Buddy 1.15.11 #3703
  • Upgrade to JUnit BOM 5.11.4 #3702

Guava

  • Upgrade to Guava 33.4.0-jre #3705

❤️ Contributors

Thanks to all the contributors who worked on this release:

@JunHyungJang @mipo256 @vladykin @Marcono1234 @sunaleed @etrandafir93 @FlorianCousin @OlivierCavadenti @jh-instant @patrickuhlmann @IvoHD @alexandra-junghans @fmbenhassine @etrandafir93 @shaikhu @cookieMr @emmanuel-ferdman @mk868

v3.26.3

09 Jul 18:07
Compare
Choose a tag to compare

🧩 Binary Compatibility

The release is:

  • Binary compatible with the previous minor version.
  • Binary incompatible with the previous patch version.

💥 Breaking Changes

Core

  • Replace assertThat(Temporal) with assertThatTemporal(Temporal) #3519

🐛 Bug Fixes

Core

  • Fix Javadoc rendering on FactoryBasedNavigableListAssert::assertThat
  • Allow ComparingNormalizedFields instances to be reused across different assertions #3493

🔨 Dependency Upgrades

Core

  • Upgrade to Byte Buddy 1.14.18 #3531
  • Upgrade to JUnit BOM 5.10.3 #3525

Guava

  • Upgrade to Guava 33.2.1-jre #3499

❤️ Contributors

Thanks to all the contributors who worked on this release:

@genuss

v3.26.0

26 May 13:22
Compare
Choose a tag to compare

💥 Breaking Changes

Core

  • Delegate OptionalDouble value comparison to Double.compare in hasValue assertion #3411

    Details

    This fixes the comparison of NaN values which wasn't working the way the hasValue Javadoc describes.

    The previous behavior can be obtained with getAsDouble:

    assertThat(OptionalDouble.of(Double.NaN).getAsDouble()).isSameAs(Double.NaN);

🚫 Deprecated

Core

  • Deprecate ObjectAssertFactory in favor of Assertions.assertThat(Object)
  • Deprecate AssertionErrorFactory in favor of AssertionErrorCreator
  • Deprecate catchThrowableOfType(ThrowingCallable, Class) in favor of catchThrowableOfType(Class, ThrowingCallable) #2823
  • Deprecate assertThat(Iterable, AssertFactory), assertThat(Iterable, Class) and their respective then variants #3453

✨ New Features

Core

  • Support multiple AfterAssertionErrorCollected callbacks #3313
  • Add InstanceOfAssertFactory for Set instances #3325
  • Add doesNotContainKey and doesNotContainKeys to Guava Multimap assertions #3334
  • Add assertions for JDK YearMonth type #3142
  • Add TemporalAssert type #3404
  • Add ignoringFieldsOfTypesMatchingRegexes #3369
  • Add fail(Throwable) and fail() variants #3204
  • Add isPrivate to Class assertions
  • Add doesNot[Start/End]WithWhitespace methods to CharSequence assertions #3441
  • Add createAssert(ValueProvider) to AssertFactory #3377
  • Add values() navigation method to AbstractMapAssert #3297
  • Add bytes()/bytes(Charset)/bytes(String) navigation methods to AbstractStringAssert #3232
  • Add doesNotThrowAnyExceptionExcept to AbstractThrowableAssert #3261
  • Add hasPermittedSubclasses to Class assertions #3316
  • Add isUnmodifiable to Iterator assertions #3477

🐛 Bug Fixes

Core

  • Preserve original order of elements when returning duplicates on doesNotHaveDuplicates #3333
  • Make isNotEqualTo(boolean) pass when actual is null #3343
  • Fix isEqualTo comparison of Timestamp instances with Instant #3410
  • Fix Instant conversion with Date assertions #3467
  • Rebuild default date formats used to parse strings as dates when default timezone or lenient flag changes #3382

⚡ Improvements

  • Avoid duplicating maven-javadoc-plugin configuration and CSS files #3371
  • Favor additionalOption entries in maven-javadoc-plugin

Core

  • Fix typo in Javadoc #3365
  • Improve AssertFactory Javadoc
  • Add Throwable stack trace to ShouldHaveCauseExactlyInstance #3351
  • Fix typo #3422
  • Add Throwable stack trace to ShouldHaveCauseInstance #3392
  • Implement boolean assertions directly in AbstractBooleanAssert and remove Booleans internal class
  • Remove stack trace elements triggered by AssertJ in addition to AssertJ elements #3449

🔨 Dependency Upgrades

Core

  • Upgrade to Byte Buddy 1.14.16 #3487
  • Upgrade to JUnit BOM 5.10.2 #3357

Guava

  • Upgrade to Guava 33.2.0-jre #3454

❤️ Contributors

Thanks to all the contributors who worked on this release:

@Achitheus @csct3434 @armandino @sbrannen @shaikhu @ryber @ranjitshinde91 @tmvlpl @valery1707 @izeye @yyytir777 @pbacz @biergit @Banuelorigni @java-coding-prodigy @vlsi @hazendaz @Kruschenstein @etrandafir93 @pbacz @dehasi

v3.25.3

04 Feb 22:04
Compare
Choose a tag to compare

🐛 Bug Fixes

  • Lock maven-clean-plugin version for all modules

Core

  • Fix a performance regression in the recursive comparison related to FieldLocation #3350
  • Don't fail when the recursive comparison checks compared fields in collection elements #3349 (proper fix: #3354)

❤️ Contributors

Thanks to all the contributors who worked on this release:

@ash211

v3.25.2

24 Jan 13:53
Compare
Choose a tag to compare

🐛 Bug Fixes

  • Fix unresolvable Javadoc stylesheet URLs, simplify configuration #3324

Core

  • Fix missing configuration for MatcherAssert soft assertions
  • Make deprecation notice visible in AbstractAssert#asList #3327
  • Recursive comparison uses equals on root object when useOverriddenEquals is enabled #3320
  • satisfiesExactlyInAnyOrder fails if actual overrides equals #3339
  • Avoid calling actual.hashCode() and expected.hashCode() in DualValue #3340
  • Recursive comparison checks for existence of fields in types that parameterize nested unordered iterables #3332

❤️ Contributors

Thanks to all the contributors who worked on this release:

@manusa @davidboden

v3.25.1

02 Jan 23:48
Compare
Choose a tag to compare

🧩 Binary Compatibility

The release is:

  • Binary compatible with the previous minor version.
  • Binary incompatible with the previous patch version.

🐛 Bug Fixes

Core

  • Revert "Provide value when assertThatThrownBy/thenThrownBy fail" #3318
  • Revert "fix: containsExactly does not work properly with maps not using equals to compare keys" #3321

v3.25.0

31 Dec 16:11
Compare
Choose a tag to compare

🚫 Deprecated

Core

  • Deprecate the following date/time related assertions in favor of isCloseTo:
    • isEqualToIgnoringHours
    • isEqualToIgnoringMinutes
    • isEqualToIgnoringSeconds
    • isEqualToIgnoringMillis
    • isEqualToIgnoringNanos
    • isInSameHourAs
    • isInSameMinuteAs
    • isInSameSecondAs
  • Deprecate asList in favor of asInstanceOf #3138

✨ New Features

Core

  • Add Descriptable#describedAs(Supplier<String>)

  • Add isInThePast and isInTheFuture to LocalDate assertions #2933

  • Add isInThePast and isInTheFuture to the missing Java 8 date/time types #2947

  • Add isRecord and isNotRecord to Class assertions #2968

  • Add hasNullValue and doesNotHaveNullValue to AtomicReferenceAssert #2969

  • Add asBoolean|Byte|Short|Int|Long|Float|Double to String assertions #2580

  • Add hasRecordComponents to Class assertions #2995

  • Add getters for field path in ComparisonDifference #3007

  • Allow to compare enum and string fields in the recursive comparison #2616

  • Provide value when assertThatThrownBy / thenThrownBy fail #3043

  • Add isSealed and isNotSealed to Class assertions #3080

  • Add assertThatCharSequence to disambiguate Groovy's GString #3132

  • Change the way the properties are collected using the Class.getMethods() API instead of iterating the class hierarchy using Class.declaredMethods() #3135

  • Add default constructor for RecursiveComparator #3206

  • Add isPrimitive and isNotPrimitive to Class assertions #2722

  • Add anyOf(ThrowingConsumer...) and allOf(ThrowingConsumer...) #3219

    Details

    What was written as:

    assertThat(elements)
      .extracting(Element::getProperty)
      .allSatisfy(p -> assertThat(p).satisfiesAnyOf(
          p1 -> assertThat(p1).isNull(),
          p1 -> assertThat(p1).isNotNull().extracting(Property::getId).isEqualTo(expected)
      ));

    can now be shortened to:

    assertThat(elements)
      .extracting(Element::getProperty)
      .allSatisfy(anyOf( // statically imported from Assertions
          p1 -> assertThat(p1).isNull(),
          p1 -> assertThat(p1).isNotNull().extracting(Property::getId).isEqualTo(expected)
      ));
  • Show the array/iterable under test in the assertion error message when it is not empty but should have been #3230

🐛 Bug Fixes

Core

  • Compare Java types from javax and com.sun by their equals method in recursive comparison #2928
  • The recursive comparison comparingOnlyFields did not treat array/iterable elements as root objects #2994
  • Fixes a bug when failing assertions on DirectoryStream types #3036
  • Fix handling of null containers in the recursive assertion #3045
  • Handle null values in map entry sets when formatting #3087
  • Fix NPE when expected and actual field values are null #3034
  • Fix NPE on anyMatch when actual contains null and Objects::isNull is used as predicate #3151
  • Fix misleading subsequence failure messages in string assertions #3166
  • Do not ignore nested fields of types specified in comparingOnlyFieldsOfTypes #3207
  • containsExactly does not work properly with maps not using equals to compare keys #2165
  • Escape percentage in shouldContainExactly error message #3288
  • Fix recursive comparison of ignored types in unordered collection #3287

⚡ Improvements

Core

  • Use Bnd feature to write resolved bndrun files to output folder #2902

  • Add Throwable stack trace to ShouldHaveClause #2872

  • Avoid copy of any Collection instance in Iterables::assertContains

  • Add Throwable stack trace to ShouldHaveRootCauseInstance and ShouldHaveRootCauseExactlyInstance #2910

  • Add missing description to nested condition #2755

  • Make nestable condition factory accept conditions on super types #2905

  • Add varargs overload to Assert::hasString and Assert::doesNotHaveString #2945

  • Improve recursive comparison performance by caching field and field names result #2979

  • Document performance cost of ignoring collection order

  • Track visited values and their comparison differences so that they can be reused #2954

  • Use hash code for compareUnorderedIterables to improve performance in some common cases #3020

  • Improve recursive comparison error message regarding equals methods used for JDK types #2678

  • Format large arrays as strings #3065

  • Remove null check as isArray already performs it

  • Fix PrimitiveArralList/TransformlingList test file names #3124

  • Add exception for usages of isEqualTo and isNotEqualTo on assertions #2921

    Details

    Before this change, the following code:

    AbstractAssert<?, ?> assertion = assertThat(something);
    assertThat(assertion).isEqualTo(assertion);

    would throw an exception with a message about equals being unsupported, suggesting to use isEqualTo instead. The message is somewhat confusing to the reader, since isEqualTo is indeed used, and is because isEqualTo internally relies on the equals of actual, which is an AbstractAssert instance and throws the exception above.

    isEqualTo and isNotEqualTo now check if actual is an assertion instance and raise an UnsupportedOperationException if so, with a message suggesting to use isSameAs and isNotSameAs instead.

    This is, for example, useful for testing custom assertion types for extension libraries, where the use of satisfies instead of isEqualTo may be desirable.

  • Add check for missing fields in recursive comparison where specific fields are requested for comparison

  • Improve efficiency of iterable string conversion #3123

  • Add more tests for usingRecursiveComparison #2790

  • Checks that compared fields exist before running the recursive comparison #3129

  • Remove maven-surefire-plugin duplicate version #3180

  • Remove Maven default goal #3182

  • Add dependency graph workflow

  • Normalize non-breaking spaces like regular white spaces #3120

  • AbstractOffsetDateTimeAssert::isBetween parameter names should use inclusive, not exclusive #3217

  • Invoke isNotNull in returns and doesNotReturn #3224

  • Cache node names in ComparingFields, ComparingProperties #3242

  • Cache node names in ComparingNormalizedFields

  • Use simpler syntax in DefaultRecursiveComparisonIntrospectionStrategy.getChildrenNodeNamesOf

  • Update to Contributor Covenant Code of Conduct v2.1

  • Correct contains assertion Javadoc to reflect method behavior in case actual is not empty and the group of values to look for is #3256

  • Fix Javadoc typos #3265

  • Improving null-safety of isEqualToNormalizingNewlines #2776

  • Speed up for BinaryDiff performance #3193

  • Upgrade workflows to Java 21 #3191

  • Apply flatten-maven-plugin to assertj-core and assertj-guava #3311

🔨 Dependency Upgrades

Core

  • Upgrade to Byte Buddy 1.14.11 #330
  • Upgrade to JUnit BOM 5.10.1 #3254
  • Upgrade to OpenTest4J 1.3.0 #3122

Guava

  • Upgrade to Guava 32.1.3-jre #3218

❤️ Contributors

Thanks to all the contributors who worked on this release:

@bjhargrave @vlsi @Ds2994 @StefanBratanov @alex859 @ascopes @ljrmorgan @ghkim3221 @hezean @matthew-leng @etellman @hjir @amodolo @armandino @aindriu-aiven @Bananeweizen @JohnBryte @ManuelG28 @maximedezette @radistao @ykardziyaka @wouterpolet @sarajuhosova @pbacz @Gabriel-Darbord @Nacho321 @marcela-cardona-s @matthiaskraaz @quaff @grigala @martinfrancois @georgebax

v3.24.2

10 Sep 14:47
Compare
Choose a tag to compare

🐛 Bug Fixes

Core

  • Remove unintentional @Deprecated from containsOnlyDigits of CharSequence assertions #2909
  • Fix a regression that caused NPE on contains of Iterable assertions when the iterable under test is an anonymous subclass of Collection #2906