Skip to content

Empty assertionCreator lambda warning is added twice  #933

@wordhou

Description

@wordhou

Affected Version: 1.7
API (fluent-en_GB, infix-en_GB): both
Platform (jvm, js): logic
Extension (none, kotlin 1.3): none

expect(oneToSeven()).notToContainFun({})

produces

"expected that subject: kotlin.sequences.SequencesKt___SequencesKt$asIterable$$inlined$Iterable$1@5453dabb        (kotlin.sequences.SequencesKt___SequencesKt$asIterable$$inlined$Iterable$1 <1414781627>)
    ◆ does not contain: 
      ⚬ an element which: 
          » at least one assertion defined: false
              » You forgot to define assertions in the assertionCreator-lambda
              » Sometimes you can use an alternative to `{ }` For instance, instead of `toThrow<..> { }` you should use `toThrow<..>()`
        ✔ ▶ number of such entries: 0
            ◾ is: 0        (kotlin.Int <449752083>)
        ✔ ▶ has at least one element: true
            ◾ is: true
        ✘ at least one assertion defined: false
            » You forgot to define assertions in the assertionCreator-lambda
            » Sometimes you can use an alternative to `{ }` For instance, instead of `toThrow<..> { }` you should use `toThrow<..>()`"

and

expect(oneToSeven()).notToContainFun({}, {toBeLessThan(3.0)})

produces

expected that subject: kotlin.sequences.SequencesKt___SequencesKt$asIterable$$inlined$Iterable$1@1b2be2e2        (kotlin.sequences.SequencesKt___SequencesKt$asIterable$$inlined$Iterable$1 <455860962>)
    ◆ does not contain: 
      ⚬ an element which: 
          » at least one assertion defined: false
              » You forgot to define assertions in the assertionCreator-lambda
              » Sometimes you can use an alternative to `{ }` For instance, instead of `toThrow<..> { }` you should use `toThrow<..>()`
        ✔ ▶ number of such entries: 0
            ◾ is: 0        (kotlin.Int <449752083>)
        ✔ ▶ has at least one element: true
            ◾ is: true
        ✘ at least one assertion defined: false
            » You forgot to define assertions in the assertionCreator-lambda
            » Sometimes you can use an alternative to `{ }` For instance, instead of `toThrow<..> { }` you should use `toThrow<..>()`
      ⚬ an element which: 
          » is less than: 3.0        (kotlin.Double <888510275>)
        ✘ ▶ number of such entries: 2
            ◾ is: 0        (kotlin.Int <449752083>)
        ✔ ▶ has at least one element: true
            ◾ is: true

Describe the bug

On IterableLike notToContain.entry/entries the empty assertionCreator lambda is getting added twice. In InAnyOrderEntriesAssertionCreator it appears to be getting added once in addEmptyAssertionCreatorLambdaIfNeccessaryand once in createExplanatoryAssertionGroup.

I added a test in this branch to take a look at this issue:
https://github.com/wordhou/atrium/blob/empty-assertion-creator-issues/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableNotToContainEntriesExpectationsSpec.kt#L106

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions