atrium icon indicating copy to clipboard operation
atrium copied to clipboard

show only failing sub assertions in a summary assertion group

Open robstoll opened this issue 5 years ago • 2 comments

Platform (all, jvm, js): all Extension (none, kotlin 1.3): none

Code related feature

Consider the following reporting

expected that subject: {a=null, null=1, b=2}        (java.util.LinkedHashMap <1031246792>)
◆ contains only, in order: 
  ✔ ▶ element 0: a=null        (java.util.LinkedHashMap.Entry <1834736756>)
      ◾ ▶ key: "a"        <528658809>
          ◾ equals: "a"        <528658809>
      ◾ ▶ value: null
          ◾ equals: null
  ✘ ▶ element 1: null=1        (java.util.LinkedHashMap.Entry <601057428>)
      ◾ ▶ key: null
          ◾ equals: null
      ◾ ▶ value: 1        (kotlin.Int <1614645392>)
          ◾ is less than: 1        (kotlin.Int <1614645392>)

Atrium could be more helpful in spotting the error for element: 1 by only showing the failing assertions:

  ✘ ▶ element 1: null=1        (java.util.LinkedHashMap.Entry <601057428>)
      ◾ ▶ value: 1        (kotlin.Int <1614645392>)
          ◾ is less than: 1        (kotlin.Int <1614645392>)

Also, I think it would be enough if the successful assertions only show that an element was successful but not the assertions behind it. So after all improvements it would look like the following:

expected that subject: {a=null, null=1, b=2}        (java.util.LinkedHashMap <1031246792>)
◆ contains only, in order: 
  ✔ ▶ element 0: a=null        (java.util.LinkedHashMap.Entry <1834736756>)
  ✘ ▶ element 1: null=1        (java.util.LinkedHashMap.Entry <601057428>)
      ◾ ▶ value: 1        (kotlin.Int <1614645392>)
          ◾ is less than: 1        (kotlin.Int <1614645392>)

In the spirit of #292, it would make sense that one can configure the assertion function to show all assertions or not within the summary assertion group. But per default, sub assertions within an summary assertion group should only be shown if failing.

robstoll avatar Dec 20 '20 21:12 robstoll

Hi! I'll do it

jakubriegel avatar Oct 16 '22 14:10 jakubriegel

@jakubriegel thanks but this isn't an easy one and I will tackle it myself in the context of another change. Please focus on another issue of you want to support Atrium

robstoll avatar Oct 16 '22 19:10 robstoll