Let's take a look at a simple test:
We might think that this test will fail because of the assertion, but the result is:
That's because the default JUnit has a dependency to hamcrest 1.1 and also the artifact org.junit:junit has some hamcrest classes inside its jar. The hasSize matcher is not present in 1.1.
To avoid this problem we need to declare following dependencies in our project:
We need to use JUnit distribution that doesn't have any hamcrest internals and we need to exclude hamcrest dependency as well. What's interesting, we will not bump into this behaviour unless our assertion throws an error.