Why doesn't this code attempting to use Hamcrest's hasItems compile?

前端 未结 9 1827
耶瑟儿~
耶瑟儿~ 2020-12-03 00:49

Why does this not compile, oh, what to do?

import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItems;

ArrayList<         


        
9条回答
  •  天命终不由人
    2020-12-03 01:12

    You can get this error if you try to replace jUnit's hamcrest with a newer version. For example, using junit-dep together with hamcrest 1.3 requires that use assertThat from hamcrest instead of jUnit.

    So the solution is to use

    import static org.hamcrest.MatcherAssert.assertThat;

    instead of

    import static org.junit.Assert.assertThat;

提交回复
热议问题