-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding new assertFailureWith #525
base: main
Are you sure you want to change the base?
Conversation
assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt
Outdated
Show resolved
Hide resolved
This addresses #511. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this variant of assertFailure
, but it was asked to be omitted when that function was first introduced. You'll have to wait to hear from a maintainer on #511
assertFailure.isInstanceOf(T::class) | ||
@Suppress("UNCHECKED_CAST") | ||
return assertFailure as Assert<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns a specialized Assert
with the new type
assertFailure.isInstanceOf(T::class) | |
@Suppress("UNCHECKED_CAST") | |
return assertFailure as Assert<T> | |
return assertFailure.isInstanceOf(T::class) |
/** | ||
* Asserts the throwable with a specific type have the expected properties for it. | ||
*/ | ||
fun <T: Throwable> Assert<T>.hasProperties(vararg pairs: Pair<KProperty1<T, Any>, Any>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated to assertFailsWith
. It's not clear why it's type parameter is bound to Throwable
subtypes since it's a general-purpose utility. I would separate it into its own PR, or even start with an issue discussing the use case and why regular .all { }
in insufficient.
Adding the new
assertFailureWith
to assert exception with a specific type and verify properties of this type.