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

ContainWithResult can have misleading failure messages with certain options #1201

Closed
coreywoodfield opened this issue Nov 3, 2023 · 1 comment
Assignees

Comments

@coreywoodfield
Copy link

coreywoodfield commented Nov 3, 2023

import org.specs2.matcher.ValueCheck
import org.specs2.mutable.Specification

class Spec extends Specification {
  "strings" should {
    "all be unique" in {
      val strings = List("foo", "foo", "bar", "qux")
      strings.map { string =>
        strings must contain(string: ValueCheck[String]).exactly(1.times)
      }
    }
  }
}

fails with the message

List(foo, foo, bar, qux) does not contain foo

which is obviously false. It's not a huge deal with such small lists, but when lists have hundreds of elements, and you just read the beginning and the end of the failure message, it can be a lot more confusing:

List(foo, bar, qux, ...) does not contain foo

The methods that change the behavior of ContainWithResult should also change the failure message.

@etorreborre
Copy link
Owner

Thanks for reporting this issue. You can see some examples of fixed messages here. I will release a new version very soon.

@etorreborre etorreborre self-assigned this Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants