i'm trying understand why junit assertion giving me compile time error:
map<string, set<string>> actual = methodtotest(); assertthat(result, hasentry("foo", new hashset<string>(arrays.aslist("bar"))));
if write way works fine:
map<string, set<string>> actual = methodtotest(); set<string> expected = new hashset<string>(arrays.aslist("bar")); assertthat(result, hasentry("foo", expected));
the compiler error first example is:
the method assertthat(t, matcher<? super t>) in type assert not applicable arguments (map<string,set<string>>, matcher<map<? extends string,? extends hashset<string>>>)
hashset<string>
subtype of set<string>
why isn't working?
hashset<string>
subtype of set<string>
true.
however, matcher<map<string,hashset<string>>>
not subset of matcher<map<string,set<string>>>
. remember list<string>
not subtype of list<object>
.
the assertthat
method expects argument of type matcher<? super map<string, set<string>>>
incompatibe matcher<map<string,hashset<string>>>
.
Comments
Post a Comment