Skip to content
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

align values in reporting #295

Open
robstoll opened this issue Jan 7, 2020 · 7 comments
Open

align values in reporting #295

robstoll opened this issue Jan 7, 2020 · 7 comments
Assignees
Milestone

Comments

@robstoll
Copy link
Owner

robstoll commented Jan 7, 2020

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.

@robstoll
Copy link
Owner Author

robstoll commented Jan 12, 2020

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
      ...

@jGleitz
Copy link
Collaborator

jGleitz commented Jan 12, 2020

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.

@robstoll
Copy link
Owner Author

Sure, I already did it for toThrow, changed also for the example

@jGleitz
Copy link
Collaborator

jGleitz commented Jan 12, 2020

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.

@jGleitz
Copy link
Collaborator

jGleitz commented Feb 3, 2020

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

@robstoll
Copy link
Owner Author

robstoll commented Feb 3, 2020

I prefer left-align when it comes to intended bullet-points, thus I would suggest we stick to left.

@robstoll
Copy link
Owner Author

robstoll commented Mar 4, 2021

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:

  1. I will remove the class name and identityHashCode -> I will re-introduce it for toBe as failure hint in case it matters
  2. I will also align the : because I think it will help in scanning the report.
  3. 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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants