Difference between hamcrest-library Matchers and hamcrest-core CoreMatchers

后端 未结 3 750
天涯浪人
天涯浪人 2021-02-04 22:55

It looks like the hamcrest org.hamcrest.Matchers class is very similar to org.hamcrest.CoreMatchers (though it looks like Matchers has mor

3条回答
  •  野性不改
    2021-02-04 23:45

    If you use Mockito a lot (as I do), you might be doing:

    import org.mockito.Mockito;
    

    or

    static import org.mockito.Mockito.*;
    

    and since the Mockito class extends Mockito's Matchers class, then you can end up with conflicts between either the Matchers classes or their static methods. Having CoreMatchers allows me to use JUnit-derived CoreMatchers in the same class as Mockito, without having to full-qualify them at their point of usage.

提交回复
热议问题