-
Notifications
You must be signed in to change notification settings - Fork 87
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
Feature Request: Add description to matchesPredicate
assertion
#514
Comments
Yes, the predicate matcher already exists. My request is to accept an optional description to improve the currently hardcoded error message. Or am I still missing something? 😃 |
Ah gotcha, I'm a little hesitant to add assertion-specific message overriding. There is some limited ability to override the message, for example you could set the name so that: assertThat(12, name = "divisible by 5").matchesPredicate { it % 5 } would give you
otherwise, I would really recommend using a custom assertion, where you can set the message exactly how you want fun Assert<X>.isSpecial() = given { actual ->
if (!it.isSpecial()) expected("${actual} to satisfy some very special requirements")
}
assertThat(x).isSpecial() |
I'm migrating my project to assertk and I have the same feature request. How do I replace my Using custom assertions to include messages feels a bit odd. |
Perhaps I can use |
yeah if something is going to be added it would be more general like |
Subscribed to #352! |
Hi 👋
It would be great if the
matchesPredicate
assertion would allow a description parameter to be displayed on an assertion error instead of satisfy the predicate.It could look something like this:
assertThat(x).matchesPredicate("some very special requirements") { it.isSpecial() }
which would then result in the error message:
I'm happy to submit a PR for this as soon as I find time for it.
The text was updated successfully, but these errors were encountered: