How does containTheSameElementsAs work in specs2

melito

This code does not match. Is this correct?

List(1, List(2, 3, List(4)), 5) must containTheSameElementsAs(List(5, List(List(4), 2, 3), 1))

Error message is following:

[error]   x be available for elements in a sequence
[error]    List(1, List(2, 3, List(4)), 5)
[error]      is missing: List(List(4), 2, 3)
[error]      must not contain: List(2, 3, List(4)) (specs2test.scala:98)
josephpconley

The containsTheSameElementsAs matcher only goes one level deep, so the match fails on your nested list as List(2, 3, List(4)) != List(List(4), 2, 3). It might be better to simply flatten your nested object before using this matcher.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

specs2 containTheSameElementsAs does not work when parameter is java.util.List

From Dev

Scala Specs2 (version 3.x) - How create and work with Notifier?

From Dev

How to assert the type of an object, in specs2

From Dev

specs2 - how to swallow exceptions

From Dev

specs2: How to use "failtrace" option

From Dev

How to group tests using specs2?

From Dev

specs2: How to use "failtrace" option

From Dev

How to assert the type of an object, in specs2

From Dev

How to skip an implementation with specs2

From Dev

How to use playframework 2.3 with specs2 2.4 instead of specs2 2.3.x

From Dev

Scala Specs2 Matchers with "aka" doesn't work

From Dev

What does "^^" mean in Scala library specs2

From Dev

What does "^^" mean in Scala library specs2

From Dev

How to show custom failure message in Specs2 (Scala)?

From Dev

How to match a top level array in json with specs2

From Dev

How to mock function returning AnyVal with Mockito in Scala / Specs2?

From Dev

Play 2.2 - specs2 - How to test futures in play 2.2?

From Dev

How to run all Specs2 tests under IntelliJ IDEA?

From Dev

Specs2: How to Test if "abc" contains all of "aabb"

From Dev

How to define input and result as DataTable in specs2?

From Dev

How to use the === syntax from Specs2 in ScalaTest

From Dev

Specs2 - "should not equal to" - how to check for non-equality?

From Dev

Why does test report "[info] No tests were executed" for ScalaTest with a single specification in specs2?

From Dev

In the specs2 framework, why does using a Scope prevent execution of a forAll quantifier?

From Dev

How to use JUnit's @Rule annotation with Scala Specs2 tests?

From Dev

Specs2: how to test a class with more than one injected dependency?

From Dev

How to use jUnit's TemporaryFolder in scala's specs2 tests?

From Dev

How to use specs2 to assert a Date is equal to another Date if their difference is less than 1 second?

From Dev

How to get meaningful message for failing Specs2 test on all elements of a collection?

Related Related

  1. 1

    specs2 containTheSameElementsAs does not work when parameter is java.util.List

  2. 2

    Scala Specs2 (version 3.x) - How create and work with Notifier?

  3. 3

    How to assert the type of an object, in specs2

  4. 4

    specs2 - how to swallow exceptions

  5. 5

    specs2: How to use "failtrace" option

  6. 6

    How to group tests using specs2?

  7. 7

    specs2: How to use "failtrace" option

  8. 8

    How to assert the type of an object, in specs2

  9. 9

    How to skip an implementation with specs2

  10. 10

    How to use playframework 2.3 with specs2 2.4 instead of specs2 2.3.x

  11. 11

    Scala Specs2 Matchers with "aka" doesn't work

  12. 12

    What does "^^" mean in Scala library specs2

  13. 13

    What does "^^" mean in Scala library specs2

  14. 14

    How to show custom failure message in Specs2 (Scala)?

  15. 15

    How to match a top level array in json with specs2

  16. 16

    How to mock function returning AnyVal with Mockito in Scala / Specs2?

  17. 17

    Play 2.2 - specs2 - How to test futures in play 2.2?

  18. 18

    How to run all Specs2 tests under IntelliJ IDEA?

  19. 19

    Specs2: How to Test if "abc" contains all of "aabb"

  20. 20

    How to define input and result as DataTable in specs2?

  21. 21

    How to use the === syntax from Specs2 in ScalaTest

  22. 22

    Specs2 - "should not equal to" - how to check for non-equality?

  23. 23

    Why does test report "[info] No tests were executed" for ScalaTest with a single specification in specs2?

  24. 24

    In the specs2 framework, why does using a Scope prevent execution of a forAll quantifier?

  25. 25

    How to use JUnit's @Rule annotation with Scala Specs2 tests?

  26. 26

    Specs2: how to test a class with more than one injected dependency?

  27. 27

    How to use jUnit's TemporaryFolder in scala's specs2 tests?

  28. 28

    How to use specs2 to assert a Date is equal to another Date if their difference is less than 1 second?

  29. 29

    How to get meaningful message for failing Specs2 test on all elements of a collection?

HotTag

Archive