robstoll / atrium-roadmap

Contains issues created by the maintainers of Atrium
1 stars 0 forks source link

reflect written assertion functions in reporting #53

Closed robstoll closed 4 years ago

robstoll commented 4 years ago

Issue is based on https://github.com/robstoll/atrium/issues/292#issuecomment-571599350 So far I had the rational that the bullet points in the reporting should reflect the assertions a developer made. For instance

expect(listOf(1,2)).containsExactly(1)

Results in

expect: [1, 2]        (java.util.Arrays.ArrayList <410495873>)
◆ contains only, in order: 
  ✔ ▶ entry 0: 1        (kotlin.Int <110771485>)
      ◾ to be: 1        (kotlin.Int <110771485>)
  ✘ ▶ size: 2        (kotlin.Int <710239027>)
      ◾ to be: 1        (kotlin.Int <110771485>)
        ❗❗ additional entries detected: 
           ⚬ entry 1: 2        (kotlin.Int <710239027>)

The size check is within the contains only, in order bullet point. The reason why I decided to do it this way is to guide newcomers. Having it first like this:

expect: [1, 2]        (java.util.Arrays.ArrayList <410495873>)
◆ size: 2        (kotlin.Int <710239027>)
  ◾ to be: 1        (kotlin.Int <110771485>)
◆ contains only, in order: 
  ✔ ▶ entry 0: 1        (kotlin.Int <110771485>)
      ◾ to be: 1        (kotlin.Int <110771485>)
        ❗❗ additional entries detected: 
           ⚬ entry 1: 2        (kotlin.Int <710239027>)

might be confusing as it looks like one wrote:

expect(listOf(1,2)
 .hasSize(1)
 .containsExactyle(1)

Due to the above linked issue I mulled this concept over and following a few thoughts:

What do you think, should remove this restriction and implement assertion functions also in other ways if we find it more suitable?

jGleitz commented 4 years ago

Hm, I think it makes sense to pull some assertions on the same level, like in the example you have given.

I noticed that atrium’s reporting has a tendency to increase in indentation very rapidly. This does not always help readability, IMHO.

Additionally, I do not think that it is really a use case to teach newcomers how to compose assertions by having them read reports. I think the reports should focuse only on understandability and clarity. Newcomers learn fast by looking at existing code and docs.

robstoll commented 4 years ago

So let's change that with 0.10.0, created https://github.com/robstoll/atrium/issues/299