Jonathan Lennox
07/06/2022, 8:37 PMSet<MyType>
. I'm writing a test that uses shouldContainExactly
to test it. When I instantiate the return value as a LinkedHashSet
it works, but when I instead instantiate it as a HashSet
I get:
Disallowed: Set can be compared only to Set
java.lang.AssertionError: Disallowed: Set can be compared only to Set
May not compare HashSet with ArrayList
expected:<*> but was:<*>
What's going on here?shouldContainExactly
requires the set to be ordered - what matcher should I use to match an unordered collection? (Also, that error message is terrible.)LeoColman
07/06/2022, 8:43 PMJonathan Lennox
07/06/2022, 8:45 PMsam
07/06/2022, 9:12 PMJonathan Lennox
07/07/2022, 6:36 PMLinkedHashSet
, and it'd fail if the actual type was a subtype? But I'm not suresam
07/07/2022, 7:46 PM