-
Notifications
You must be signed in to change notification settings - Fork 0
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
simplify reporting of Iterable.contains values assertions #56
Comments
Interesting question. Can |
We could have:
my only concern, the difference is very subtle. A synonym for atLeast(1) could be
Edit as the default case is report only failure, it makes more sense to use |
Another thing we should keep in mind: one can also report holding assertions where IMO it can make sense to use/show the occurrences. E.g. for reviews:
might give a clue to the reviewer that the test-code is written wrong and it should actually be |
I second that concern. I fear that it will be irritating to users when to use what. My proposal: Handle “atLeast(1)” as a special case in reporting because it is so common. So
without any further mentioning of a number of occurrences means “at least one”. This is consistent with the normal use in the English language. So we can then do
without having to introduce new assertion functions. |
I would be in favour of changing We can add a flag as shown once we have HTML reporting where it might make sense in certain scenarios to show the occurrence. And I would not introduce a shortcut |
Taken from #55 (comment) written by @igorakkerman:
The author doesn't care about the cardinality of the item. All that matters is: We wanted an item, we didn't get it. Hence:
Following the current output:
I agree that we could improve the reporting for contains values assertions. Personally I think we can remove the
but no such item was found.
as we report only failures but we can also leave it as additional hint, totally fine with me.One note on the implementation.
contains(...)
is currently a shortcut forcontains.inAnyOrder.atLeast(1).values(...)
the verbose output is due to the generic implementation which uses the same forcontains.inAnyOrder.atLeast(2).butAtMost(5).values(...)
where the number of occurrences is important.Thus the question, shall we report the number of occurrences if one uses
contains.inAnyOrder.atLeast(1).values(...)
and not the shortcut -- which means it wouldn't be a shortcut any more or rather we would have to add a configuration option to the reporting of atLeast.Thoughts?
The text was updated successfully, but these errors were encountered: