-
Notifications
You must be signed in to change notification settings - Fork 624
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
Add shouldContainAllIgnoringFields #3394
Add shouldContainAllIgnoringFields #3394
Conversation
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.
LGTM overall.
Consider handling large collections (AssertionsConfig.maxCollectionEnumerateSize
)
Perhaps some KDoc on the assertions, as well as the kotest.io docs
What do you think about null-handling? Should this pass?
data class Person(val name: String, age: Int)
val sammy = Person("Sammy", 20)
val sara = Person("Sara", 27)
listOf(sammy, sara, null).shouldContainAllIgnoringFields(
listOf(null, sara.copy(age = 28), sammy),
Person::age
)
Thanks @Kantis , |
I'm not sure why it's not used everywhere. I think it's been added incrementally whenever we had someone who cared enough about lack of readability in outputs :) but I would have to do some digging in git to get the whole picture.. Looking around a bit more I think we should probably use
listOf(1, 2, null, 3, null).shouldContainAll(1, 2, null) // passes
listOf(1, 2, 3).shouldContainAll(1, 2, null)
// fails: Collection should contain all of [1, 2, <null>] but was missing [<null>] |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
…fiields-in-any-order
…fiields-in-any-order
…fiields-in-any-order
@sherviiin do you mind adding maxCollectionPrintSize support and then we can merge. |
Hey @sksamuel , |
…fiields-in-any-order
…fiields-in-any-order
…fiields-in-any-order
Add shouldContainAllIgnoringFields() which compares collections ignoring one or more fields, in any order