Releases: willowtreeapps/assertk
Releases · willowtreeapps/assertk
0.28.1
v0.28.0
[0.28.0] 2023-12-05
Changed
- Minimum supported kotlin version is 1.9.21
- Rename
isSameAs/isNotSameAs
toisSameInstanceAs/isNotSameInstanceAs
to make it more clear they
use are about instance identity, old name is deprecated - Rename
containsAll
tocontainsAtLeast
to make it more clear that the collection can contain additional elements,
old name is deprecated - Bytes are shown as hex on all supported platforms (previously it was only on the jvm)
- If
isEqualTo
fails and the expected and actual display the same string, print a disambiguation message, ex:expected:<4> with type:<class kotlin.Int> but was type:<class kotlin.Short> with the same string representation
Breaking Changes
- Binary-breaking change as previous error-level deprecations were removed
Added
- Added
doesNotContainKey
assertion forMap
Fixed
- Fixed incorrect usage of contains in some kdoc examples
- Exceptions being swallowed if thrown in a soft assertion block
- More correctly re-throw fatal error in the jvm
v0.27.0
[0.27.0] 2023-09-13
Changed
- Minimum supported kotlin version is 1.9.0
- Added support for WASM targets (note: this only applies to the core library
and not assertk-coroutines as the coroutines library doesn't have a stable
release for it yet)
Breaking Changes
- Previous
assertThat {}
deprecation warning is now an error
v0.26.1
v0.26
[0.26] 2023-05-12
Changed
- Minimum supported kotlin version is 1.8.10
- Minimum supported coroutines version is 1.7.0
- When asserting on a
Throwable
or failedResult
, their exception is added as the cause to any
AssertionError
s which are thrown as the result of an assertion failure. - Removed second type parameter on
Any.isInstanceOf
extension. In practice this would generally widen
toAny
which is what it has been replaced with.
Breaking Changes
- Previous deprecations are now errors
Added
- Added
assertFailure { }
entrypoint which is a shorthand forassertThat(runCatching { .. }).isFailure()
- Added
first
andsingle
assertion forIterable
- Added
containsMatch
assertion forCharSequence
.
Unlike 'contains' this is a regex rather than a literal.
Unlike 'matches' this looks for a subset of theCharSequence
to match rather than the entire contents. - Added reified overloads of
hasClass
,doesNotHaveClass
,isInstanceOf
, andisNotInstanceOf
.
For example:isInstanceOf<String>()
. - Added sequence assertions to mirror iterable
- Added array assertions for
UByteArray
,UShortArray
,UIntArray
, andULongArray
.
Deprecated
- Lambda-accepting
assertThat { }
entrypoint is now deprecated.
UseassertThat(T)
for normal values orassertFailure { }
for exception-throwing code.
Fixed
- Fixed iterable assertions that take a block that could have multiple assertions.
Includes:none
,atLeast
,atMost
,exactly
, andany
v0.25
[0.25] 2021-09-12
Changed
- Minimum supported kotlin version is 1.5.30
- Minimum supported coroutines version is 1.5.2
- Replaced custom result type returned from
assertThat {}
withkotlin.Result
. This is a binary-incompatible change,
but it should be source-compatible in most cases as referencing the custom result type directly was discouraged.
Added
- Added
startsWith()
andendsWith()
forList
. - Added
Optional<>.isPresent()
,Optional<>.isEmpty()
,Optional<>.hasValue()
- Added expanded set of apple targets for kotlin native.
Fixed
- Fixed behavior of
isEqualToIgnoringGivenProperties
to only check accessible properties. - Added
prop
which can take a member function. This restores much of the functionality deprecated
in 0.23, while preserving the useful type-safety of the new overloads.
v0.24
v0.23.1
[0.23.1] 2021-02-03
Fixed
- Fixed
containsExactly
failing on custom list types. - Fixed NullPointerException in
isDataClassEqualTo
when a property is null. - Fixed multiple failures breaking
any
- Fixed map's
containsOnly
to ensure keys match up with values. - Fixed map's contain methods null handling.
v0.23
Changed
- Minimum supported kotlin version is 1.4.0
- Multiplatform artifacts are published as a single artifact. You can now just write
sourceSets { commonTest { dependencies { implementation "com.willowtreeapps.assertk:assertk:..." } } }
instead of defining one for each platform.
- Added support for the Kotlin/JS IR compiler
- Added optional
displayActual
function toassertThat
as an alternative to.toString()
for external types - Moved most
String
assertions toCharSequence
Added
- Added
prop
function withKProperty1
argument. - Added
containsExactlyInAnyOrder
assertion forIterable
and primitive arrays - Added initial Coroutines artifact (additional support planned for the future)
Deprecated
- Deprecated
prop
function withKCallable
argument. Use the new overload
with type-safeKProperty1
argument or another overload with explicit name and lambda.
Fixed
- Primitive array 'contains' methods now work with NaN. ex:
will pass when it failed before.
assertThat(floatArrayOf(Float.Nan)).contains(Float.NaN)
- Fixes a bug causing failures to sometimes be dropped in a nested assertion context
v0.22
Added
- Add multi-value support for
Assert<String>.contains()
anddoesNotContain()
- Add
isEqualByComparingTo
to compare objects bycompareTo
instead ofequals
this is useful for cases like
BigDecimal
whereequals
would fail because of differing precision. - Add
containsOnly
for arrays.
Changed
- Minimum supported kotlin version is 1.3.70
- Updated opentest4j to 1.2.0. This changes the multiple assertion message to include each exception class name.
- Moved
containsAll
,containsNone
, andcontainsOnly
fromCollection
toIterable
to make
them a bit more flexible. containsAll
,containsNone
, andcontainsOnly
error messages now include the expected and actual lists.- Unwrap exceptions thrown by
prop(callable: KCallable<*>)
to make them more clear. - Add all exception stacktraces to a
MultipleFailuresError
withThrowable.addSurpressed
on the jvm (used when
collecting multiple exceptions withassertAll
). Unfortunately, if you are using gradle you won't see this due to a
known gradle issue. - No longer wrap exceptions in
AssertionError
s when usinggiven
andtransform
. Warning: this is techinicaly a
breaking change as code like:will no longer be caught. But you shouldn't be writing code like that anyway ;)try { assertThat(foo).given { throw MyException("error") } } catch (e: AssertionError) { // assume caught }
Fixed
- Don't let
assertAll
captureOutOfMemory
errors.
Breaking Changes
- Previously deprecated methods (as of 0.18) are now errors.