-
-
Notifications
You must be signed in to change notification settings - Fork 211
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 option to display only unexpected or missing elements in asserts on collections #292
Comments
taking a look at an example for the discussion:
and the output:
Would you expect that the hint about the size shows up nonetheless or also only if it failed? Would you personally also use it for Map contains functions? (I intend to add features only if people actually use it) |
Thank you for being so open for feedback. Since you're asking about my personal preferences:
|
Well, thanks for sharing your valuable feedback 👍
Its output (only showing failures, thus I have removed ✔/✘ marks)
would you still place the size including the |
I'd put the size above, as it feels like a kind of summary to me. In most tests from other people, I've even seen the size to be asserted before the content, as a fail fast test. I'd leave the additional entries below, though. Using Atrium, I found "to be" as a bit weird in the list (despite understanding where it comes from). For the size values, the hashes have no value, are rather confusing and can be left out. I'd personally prefer:
The overall rationale: as visual as possible. When reading the test result, I want to immediately know what was expected, what was the actual value and what is the difference, all without even turning my brain on ;) |
I see a point where Atrium could improve due to your feedback: align values in reporting. This would require a different way we produce the reporting as we don't have knowledge about previous or future assertions which will be added to the list in addition. I have created another issue (#295) where we can discuss it. On the other hand, you could already:
Let me know in case you want to try it out one of the two (or both) and need help. Over all I see it realistic that it could look as follows in the end for you (in case we align values as well):
IMO it might be confusing if |
I agree that the size check is confusing if it comes first at the level of the entries. If they have to stay at the "triangle" level, it's better to have them elsewhere... |
moving the size check out of the contains assertion is covered in #299 |
@igorakkerman quite a while since you asked for the feature. Sorry about that, was something I had no need for myself (still don't have it) and no one volunteered / sponsored the issue. Anyway... expect(veryLongList).toContainExactly(1, 2, 3, reportingOptions = { showOnlyFailing() })
expect(veryLongList).toContain.inOrder.only.values(1, 2, 3, reportingOptions = { showOnlyFailing() }) What do you think? |
@robstoll Unfortunately, I have moved away from Atrium. But if I were using it, I would prefer a shorter syntax like |
@igorakkerman Thanks for the feedback, looks good to me as well. |
I decided that I will apply a default heuristic so that (I hope) most users don't have to change reporting options.
I decided that I will apply a default heuristic so that (I hope) most users don't have to change reporting options.
I decided that I will apply a default heuristic so that (I hope) most users don't have to change reporting options.
…-too-many-elements #292 show only failing for inOrder.only if more than 10 elements
Hi, when an assert on elements of large collections fails, it would be very helpful to only see "bad" items, not those that were expected. Currently, all elements in the collection are shown.
For instance, with
containsExactly
/contains.inOrder.only.entries
, a section is dedicated to every single element, the encountered element is equal to the expected one or not. A correct element is annotated using a ✔️. A wrong element at the index, it is marked with an ✘.When dealing with a large number of elements, it can be tedious to find the bad elements. The test author should be able to indicate which elements should be displayed, all elements or only the differences between good and bad elements.
This could be achieved using an optional boolean flag
showAll
, defaulting totrue
, or an optionaldisplayFlags
object or enumeration, for example. The option could be selected individually for every assertion or through a global property.See also this discussion on Slack:
https://kotlinlang.slack.com/archives/C887ZKGCQ/p1578313112006400
The text was updated successfully, but these errors were encountered: