October 2016
Intermediate to advanced
198 pages
3h 52m
English
We covered the most basic of the Matchers in the previous section. Further on, we have some more Matchers that are not as generic as the basic Matchers from last section.
We can test if a container has a particular element:
listOfNames should contain("Bob")This can be used with any type T that has an implicit type org.scalatest.enabler.Containing[T]. In the Containing companion object, implicits are provided for types GenTraversable[E], java.util.Collection[E], java.util.Map[K, V], String, Array[E], and Option[E].
(List("Hi", "Di", "Ho") should contain ("ho")) (after being lowerCased)Note that when you use the explicitly DSL with contain, you need to wrap the entire contain expression in parentheses.
The ...
Read now
Unlock full access