Simplify shouldMatchInOrder and shouldMatchEach #3911
Labels
assertions 🔍
Related to the assertion mechanisms within the testing framework.
enhancement ✨
Suggestions for adding new features or improving existing ones.
Milestone
The extension functions
shouldMatchInOrder
andshouldMatchEach
are great to assert collections. However, the signature could be a bit improved in my view. Intuitively, if I want to customize the assertion of the collection elements, I will want to pass the collections and some lambda that receives the actual and expected elements to be asserted.I mean a signature like this:
This allows you to do something like this:
Instead of:
I mean, looking at both variants when they are there does feel kind of obvious and not so different from each other. But if you have to write something like this for the first time, it does require some elaboration until you get the twist of it, as you don't see this immediately by just looking at the signature. I believe with my suggested signatures it's immediately clear what it's supposed to do.
In my project, I have added the following extension functions to solve this problem. Would you maybe consider adding this to the library?
I also have overloads for Sequences:
Is there any particular reason why in the library there are overloads for Iterable, Array and List but not for Sequence?
The text was updated successfully, but these errors were encountered: