align values in reporting
robstoll opened this issue · 7 comments
Platform (jvm, js, android): all
Extension (none, kotlin 1.3, jdk8): none
Code related feature
expect(1).toBe(12)
The current output:
expect: 1 (kotlin.Int <1459794865>)
◆ to be: 12 (kotlin.Int <1447689627>)
Maybe it would be more readable if we align the values? As follows:
expect: 1 (kotlin.Int <1459794865>)
◆ to be: 12 (kotlin.Int <1447689627>)
Of course, this is a very simple example and it can get quickly more complicated where it might not be so obvious how we should align, consider the following:
expect("hello world").startsWith("hi").endsWith("robert").contains("World")
the current output
expect: "hello world" <152134087>
◆ starts with: "hi" <1620303253>
◆ ends with: "robert" <1620303254>
◆ contains:
⚬ value: "World" <395629617>
⚬ ▶ number of occurrences: 0
◾ is at least: 1
maybe like this?
expect: "hello world" <152134087>
◆ starts with: "hi" <1620303253>
◆ ends with: "robert" <1620303253>
◆ contains:
⚬ value: "World" <395629617>
⚬ ▶ number of occurrences: 0
◾ is at least: 1
Still a bit clearer to read than the current output IMO but I am not sure if the effort is worth the result. Thoughts?
Please react with 👍 if you would like to see this feature implemented in Atrium, the more upvotes the more likely I will implement it myself -- feel free to sponsor me, that would be a motivation too.
You are of course welcome to work on this issue. Write I'll work on it
as comment so that we can assign the task to you.
another motivating example:
expect: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>)
◆ ▶ thrown exception when called: java.lang.IllegalArgumentException
◾ is instance of type: IllegalStateException (java.lang.IllegalStateException)
» Properties of the unexpected IllegalArgumentException
...
aligning would help here as well (and change the representation of thrown Excepion:
expect: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>)
◆ ▶ thrown exception when called: IllegalArgumentException (java.lang.IllegalArgumentException)
◾ is instance of type: IllegalStateException (java.lang.IllegalStateException)
» Properties of the unexpected IllegalArgumentException
...
If we actually do this, can we please also align the information in parentheses? I feel that this would make it easier for me to scan the output.
Sure, I already did it for toThrow, changed also for the example
changed also for the example
I’d expect the (readme …
parentheses also to be indented like the others are.
I think the rationale is that I usually do not need the information given there, I only use it when I need it to understand the reporting better or find bugs.
Would it make sense to right-align the description texts? Like this:
expected that subject: "foo bar" <428663760>
◆ equals: "baz" <544419202>
instead of:
expected that subject: "foo bar" <428663760>
◆ equals: "baz" <544419202>
pro: description and value are close together
con: bullet point and description are far apart
I prefer left-align when it comes to intended bullet-points, thus I would suggest we stick to left.
As I plan to do a refactoring in the area of the reporter, I am going to see if I can address this issue in the same go. I plan to do something slightly different than shown in the description:
- I will remove the class name and identityHashCode -> I will re-introduce it for toBe as failure hint in case it matters
- I will also align the
:
because I think it will help in scanning the report. - I will most likely change the bullet points to characters which have a monospaced width
So instead of (as shown above):
expect: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>)
◆ ▶ thrown exception when called: IllegalArgumentException (java.lang.IllegalArgumentException)
◾ is instance of type: IllegalStateException (java.lang.IllegalStateException)
» Properties of the unexpected IllegalArgumentException
...
it will look like as follows (bullet points not yet adjusted)
expect : () -> kotlin.Nothing
◆ ▶ thrown exception when called : IllegalArgumentException (java.lang.IllegalArgumentException)
◾ is instance of type : IllegalStateException (java.lang.IllegalStateException)
» Properties of the unexpected IllegalArgumentException
...
Another example, instead of:
expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.FeatureExtractorSpec$1$Person <1234789>)
◆ ▶ firstName: "Robert" <1234789>
◾ starts with: "Pe" <1234789>
◾ ends with: "er" <1234789>
◆ ▶ lastName: "Stoll" <1234789>
◾ equals: "Dummy" <1234789>
it will look as follows:
expected that subject : Person(firstName=Robert, lastName=Stoll, isStudent=false)
◆ ▶ firstName : "Robert"
◾ starts with : "Pe"
◾ ends with : "er"
◆ ▶ lastName : "Stoll"
◾ equals : "Dummy"