I was looking for a ScalaTest matcher to check that a list contains all of the needed elements (given within another list), but that may also be others.
contai
Another possible solution is:
import org.scalatest.Inspectors.forAll
forAll(list) { wanted should contain(_) }
Expect an error message similar to this:
scala> forAll(List(1, 2)) { List(1) should contain(_) }
org.scalatest.exceptions.TestFailedException: forAll failed, because:
at index 1, List(1) did not contain element 2 (:18)
in List(1, 2)
...
Caused by: org.scalatest.exceptions.TestFailedException: List(1) did not contain element 2