I am testing the behavior of a class using the SortedSet of Library objects (a regular class is not an interface, so I brought cglib-nodep). I need to check the behavior of a class when a sorted set has multiple objects. Library objects were mocked this way:
Library library = Mock()
Library library2 = Mock()
Then I create a TreeSet:
def libraries = [library, library2] as TreeSet
and call the system under the test method:
sut.doStuff(libraries).
When I debug this test, I see that the libraries are a SortedSet with one element. This, apparently, is a consequence of how Spock deals with equality:
def "equality test"() {
expect:
library == library2
}
passes when I run the test. Is there a way I can get around this behavior?
EDIT: Changed = to == because I cannot print