atrium icon indicating copy to clipboard operation
atrium copied to clipboard

fix: display mismatch reasons in "following elements were mismatched"

Open vlsi opened this issue 2 years ago • 1 comments

Fixes https://github.com/robstoll/atrium/issues/1359


I confirm that I have read the Contributor Agreements v1.0, agree to be bound on them and confirm that my contribution is compliant.

vlsi avatar Mar 18 '23 10:03 vlsi

The fix makes

        expect(listOf(User("joe", "qwerty"), User("j", "qwerty1"))) {
            toHaveElementsAndAll {
                feature("login", { login })
                    .feature("size", { length })
                    .because("login should be longer than one letter") {
                        toBeGreaterThan(1)
                    }
                feature("password", { password })
                    .because("password should be secure") {
                        notToEqual("qwerty")
                    }
            }
        }

to produce

I expected subject: [User(login=joe, password=qwerty), User(login=j, password=qwerty1)]        (java.util.Arrays.ArrayList <1937662030>)
◆ elements need all: 
    » ▶ login: 
        ◾ ▶ size: 
            ◾ to be greater than: 1        (kotlin.Int <987792975>)
            ℹ because: login should be longer than one letter
    » ▶ password: 
        ◾ not to equal: "qwerty"        <952055826>
        ℹ because: password should be secure
    ❗❗ following elements were mismatched: 
       ⚬ ▶ index 0: User(login=joe, password=qwerty)        (ch.tutteli.atrium.api.fluent.en_GB.samples.ThrowableFeatureExtractorSamples$messageFeature2$User <1635068416>)
           ◾ ▶ login: "joe"        <1130906588>
               ◾ ▶ size: 3        (kotlin.Int <439323450>)
                   ◾ to be greater than: 1        (kotlin.Int <987792975>)
                   ℹ because: login should be longer than one letter
           ◾ ▶ password: "qwerty"        <952055826>
               ◾ not to equal: "qwerty"        <952055826>
               ℹ because: password should be secure
       ⚬ ▶ index 1: User(login=j, password=qwerty1)        (ch.tutteli.atrium.api.fluent.en_GB.samples.ThrowableFeatureExtractorSamples$messageFeature2$User <1133787119>)
           ◾ ▶ login: "j"        <44754983>
               ◾ ▶ size: 1        (kotlin.Int <987792975>)
                   ◾ to be greater than: 1        (kotlin.Int <987792975>)
                   ℹ because: login should be longer than one letter
           ◾ ▶ password: "qwerty1"        <1254614872>
               ◾ not to equal: "qwerty"        <952055826>
               ℹ because: password should be secure

The following should probably be hidden:

           ◾ ▶ login: "joe"        <1130906588>
               ◾ ▶ size: 3        (kotlin.Int <439323450>)
                   ◾ to be greater than: 1        (kotlin.Int <987792975>)
                   ℹ because: login should be longer than one letter

...

           ◾ ▶ password: "qwerty1"        <1254614872>
               ◾ not to equal: "qwerty"        <952055826>
               ℹ because: password should be secure

vlsi avatar Mar 18 '23 10:03 vlsi