unit testing - Java Hamcrest : Collection contains item of type -
i'd assert list<achievement>
contains member of type testachievement
.
here's assertion:
list<achievement> achievements; // populated elsewhere assertthat(achievements,hasitem(isa(testachievement.class)));
this doesn't compile, reporting error:
the method assertthat(t, matcher) in type assert not applicable arguments (list, matcher<iterable<testachievement>>)
what's correct syntax type of assertion using hamcrest?
thanks help.
the posts here suggested defect hamcrest, headed on hacmrest site register bug, whien discovered mvn / ivy dependency declaration using out-of-date, giving me old version of hamcrest.
this bug exists 1.1, latest if declared using
<dependency org="org.hamcrest" name="hamcrest-all" rev="1.1">
however, correct depedency declaration is:
<dependency org="org.hamcrest" name="hamcrest-library" rev="1.3.rc2"/>
updating solved issue. syntax used in test is:
assertthat(achievements, hasitem(isa(testachievement.class)));
Comments
Post a Comment